Please take me off the list Thanks
On Thu, Sep 25, 2014 at 1:04 PM, <[email protected]> wrote: > Send users mailing list submissions to > [email protected] > > To subscribe or unsubscribe via the World Wide Web, visit > http://lists.racket-lang.org/users/listinfo > or, via email, send a message with subject or body 'help' to > [email protected] > > You can reach the person managing the list at > [email protected] > > When replying, please edit your Subject line so it is more specific > than "Re: Contents of users digest..." > > > [Racket Users list: > http://lists.racket-lang.org/users ] > > > Today's Topics: > > 1. htdp: exercise 21.1.3 (Daniel Bastos) > 2. Re: web server: module servlets (George Neuner) > 3. ANN: DOS, Delimited-continuation-based Operating-system > Simulator (Jay McCarthy) > 4. Re: web server: module servlets (Jay McCarthy) > > > ---------------------------------------------------------------------- > > Message: 1 > Date: Thu, 25 Sep 2014 13:48:05 -0300 > From: Daniel Bastos <[email protected]> > To: Racket Users <[email protected]> > Subject: [racket] htdp: exercise 21.1.3 > Message-ID: > <cab08-qr1mmdnj6usztfx+qnjmgh3qyztk5ic3_xwimhkz-o...@mail.gmail.com> > Content-Type: text/plain; charset="utf-8" > > The solution is missing, but I thought of exposing this one here so that it > gets scrutinized before sending it to Robby Findler. > > ;; Exercise 21.1.3. Define natural-f, which is the abstraction of the > ;; following two functions: > ;; > ;; ;; copy : N X -> (listof X) > ;; ;; to create a list that contains > ;; ;; obj n times > ;; (define (copy n obj) > ;; (cond > ;; [(zero? n) empty] > ;; [else (cons obj > ;; (copy (sub1 n) obj))])) > ;; > ;; ;; n-adder : N number -> number > ;; ;; to add n to x using > ;; ;; (+ 1 ...) only > ;; (define (n-adder n x) > ;; (cond > ;; [(zero? n) x] > ;; [else (+ 1 > ;; (n-adder (sub1 n) x))])) > ;; > ;; Don't forget to test natural-f. Also use natural-f to define > ;; n-multiplier, which consumes n and x and produces n times x with > ;; additions only. Use the examples to formulate a contract. > ;; > ;; Hint: The two function differ more than, say, the functions sum and > ;; product in exercise 21.1.2. In particular, the base case in one > ;; instance is a argument of the function, where in the other it is just > ;; a constant value. > ;; > ;; (*) Solution > ;; > ;; After following the design recipe for abstraction, we get natural-f as > ;; shown below. To write the contract, let's first only consider copy, > ;; then we consider only n-adder and then we consider both. > ;; > ;; ;; natural-f-copy: Nat X (X (listof X) -> (listof X)) (listof X) -> > (listof X) > ;; ;; natural-f-adder: Nat number (number number -> number) number -> number > ;; > ;; The contract for natural-f-adder is more specific than > ;; natural-f-copy. The difference between these is that in the first, two > ;; different types are involved --- X and (listof X). Therefore, (listof > ;; X) works as another variable, so let's call it Y in the final version. > > ;; natural-f: Nat X (X Y -> Y) Y -> Y > (define (natural-f n x f init) > (cond > [(zero? n) init] > [else (f x > (natural-f (sub1 n) x f init))])) > > ;; (*) Tests > > ;; Let's use two different types in copy, say symbol and then number. > > (check-expect (copy 3 'a) '(a a a)) > (check-expect (natural-f 3 'a cons empty) (copy 3 'a)) > > (check-expect (copy 0 'a) empty) > (check-expect (natural-f 0 'a cons empty) (copy 0 'a)) > > (check-expect (copy 3 1) (list 1 1 1)) > (check-expect (natural-f 3 1 cons empty) (copy 3 1)) > > ;; For n-adder, let's make sure to test different init-values. > > (check-expect (n-adder 3 3.14) 6.14) > (check-expect (natural-f 3 1 + 3.14) (n-adder 3 3.14)) > > (check-expect (n-adder 3 1) 4) > (check-expect (natural-f 3 1 + 1) (n-adder 3 1)) > > (check-expect (n-adder 3 2) 5) > (check-expect (natural-f 3 1 + 2) (n-adder 3 2)) > -------------- next part -------------- > An HTML attachment was scrubbed... > URL: > <http://lists.racket-lang.org/users/archive/attachments/20140925/ea097a92/attachment-0001.html> > > ------------------------------ > > Message: 2 > Date: Thu, 25 Sep 2014 12:51:56 -0400 > From: George Neuner <[email protected]> > To: Jay McCarthy <[email protected]> > Cc: users <[email protected]> > Subject: Re: [racket] web server: module servlets > Message-ID: <[email protected]> > Content-Type: text/plain; charset="utf-8"; Format="flowed" > > Hi Jay, > > On 9/23/2014 10:03 PM, Jay McCarthy wrote: >> The command-line tool is basically deprecated and only provided for >> backwards compatibility. There is a huge amount that it can't do at >> all and it hasn't been the primary way that we recommend using the Web >> server for a very long time. > > I'm not using the plt-web-server app - I created a minimal application > that set up the environment: directories, ports, etc. and a start > function that just returns a 404 if called. My server sits behind > Apache and only handles servlets, which I would like to be demand load > modules so they can be added to and updated easily. That's why I am > interested in being able to unload servlets on command, though not > necessarily all of them at once (although that also is helpful). > > >> > Not really knowing much about Racket's internals he naively asks: >> >Coulda server pre-load the commonly used webserver modules and make >> >themavailableto new module servlets, or does the custodian >> >implementation make doing thatdifficult/impossible? >> >> This is the purpose of the make-servlet-namespace argument of >> configuration-table->web-config@ but there is no option in the >> configuration file for that argument. >> >> http://docs.racket-lang.org/web-server-internal/Web_Servers.html?q=servlet-namespace#%28def._web-config._%28%28lib._web-server%2Fweb-config-unit..rkt%29._configuration-table-~3eweb-config~40%29%29 > > The namespace facility seems designed more for user written modules than > for library modules. > > My analysis may be off-base as I have very little experience working > directly with custodians, but it seems that when a dynamic servlet is > first loaded, its custodian spends a lot of additional time (re)loading > library modules that already exist in other custodians. [ Though I can't > tell exactly what's happening, I can see a lot of disk activity when I > think I'm loading a 5KB servlet. ] Reasonably I would have expected > that after loading/linking the first servlet, the libraries common to > the servlets would be already in memory. But loading additional servlets > is no quicker [ and causes a similar disk hit ] so clearly I don't > understand what is happening internally with the custodians. > > If a Racket library is deliberately put into the servlet-namespace, does > that streamline linking? > > >> > My application so far is based on stateful servlets and AJAX ... stateful >> > mainly because it's easier for me to understand. Currently there is >> >little use ofcontinuations, but some planned functionality will use them >> > extensively and it certainly wouldhelp if debugging didn't always mean >> >starting over setting up conditions in theapplication. >> >> This comment/question is related to questions 4 and 5 from the FAQ: >> >> http://docs.racket-lang.org/web-server/faq.html?q=servlet-namespace#%28part._update-servlets%29 > > That link leads to a "troubleshooting" page 8-). I didn't consider the > issue to be a "problem" per se - I already knew that restarting a > stateful servlet would lose saved state. Most of my existing servlets > are one-shots that don't save any state, but they are written using the > stateful language. Only a few use continuations and not extensively (so > far). I was just thinking ahead to stuff that will need to use > continuations more extensively. > > Thanks for putting up with my questions. > George > > -------------- next part -------------- > An HTML attachment was scrubbed... > URL: > <http://lists.racket-lang.org/users/archive/attachments/20140925/7c368b80/attachment-0001.html> > > ------------------------------ > > Message: 3 > Date: Thu, 25 Sep 2014 13:02:00 -0400 > From: Jay McCarthy <[email protected]> > To: users <[email protected]> > Subject: [racket] ANN: DOS, Delimited-continuation-based > Operating-system Simulator > Message-ID: > <CAJYbDam0maAG7ZmCBjbha1uqhJyCpX9J+L3=kxqal4gjdku...@mail.gmail.com> > Content-Type: text/plain; charset=UTF-8 > > I've just released the game architecture library I talked about in > part 2 of my RacketCon talk. > > The big picture of this library is to make World-style programs more > compositional by (a) using continuations to hide the internal state > (including control state) of components and (b) using environments as > a standard monoid-based inter-component communication channel. A > monoid is used to ensure that the components can be evaluated in any > order. Despite assumptions some have about continuations and pure > functional programming, it is incredibly efficient and can run at > 60FPS, as demonstrated in get-bonus. > > You can get it with > > raco pkg install dos > > And you can try out the demo with > > racket -l dos/examples/win > > The demo source is a bare 39 lines: > > https://github.com/jeapostrophe/dos/blob/master/dos/examples/win.rkt > > and I provide the non-DOS version for comparison: > > https://github.com/jeapostrophe/dos/blob/master/dos/examples/win-long.rkt > > The core library has a mere 36 lines: > > https://github.com/jeapostrophe/dos/blob/master/dos/main.rkt > > -- > Jay McCarthy > http://jeapostrophe.github.io > > "Wherefore, be not weary in well-doing, > for ye are laying the foundation of a great work. > And out of small things proceedeth that which is great." > - D&C 64:33 > > > ------------------------------ > > Message: 4 > Date: Thu, 25 Sep 2014 13:04:44 -0400 > From: Jay McCarthy <[email protected]> > To: George Neuner <[email protected]> > Cc: users <[email protected]> > Subject: Re: [racket] web server: module servlets > Message-ID: > <CAJYbDa=-durmvy7jnct32y8wag2+qkhzqw5cvdl4l_d6zth...@mail.gmail.com> > Content-Type: text/plain; charset=UTF-8 > > On Thu, Sep 25, 2014 at 12:51 PM, George Neuner <[email protected]> wrote: >> Hi Jay, >> >> On 9/23/2014 10:03 PM, Jay McCarthy wrote: >> >> The command-line tool is basically deprecated and only provided for >> backwards compatibility. There is a huge amount that it can't do at >> all and it hasn't been the primary way that we recommend using the Web >> server for a very long time. >> >> >> I'm not using the plt-web-server app - I created a minimal application that >> set up the environment: directories, ports, etc. and a start function that >> just returns a 404 if called. My server sits behind Apache and only handles >> servlets, which I would like to be demand load modules so they can be added >> to and updated easily. That's why I am interested in being able to unload >> servlets on command, though not necessarily all of them at once (although >> that also is helpful). >> >> >>> Not really knowing much about Racket's internals he naively asks: >>> Could a server pre-load the commonly used webserver modules and make >>> them available to new module servlets, or does the custodian >>> implementation make doing that difficult/impossible? >> >> This is the purpose of the make-servlet-namespace argument of >> configuration-table->web-config@ but there is no option in the >> configuration file for that argument. >> >> http://docs.racket-lang.org/web-server-internal/Web_Servers.html?q=servlet-namespace#%28def._web-config._%28%28lib._web-server%2Fweb-config-unit..rkt%29._configuration-table-~3eweb-config~40%29%29 >> >> >> The namespace facility seems designed more for user written modules than for >> library modules. >> >> My analysis may be off-base as I have very little experience working >> directly with custodians, but it seems that when a dynamic servlet is first >> loaded, its custodian spends a lot of additional time (re)loading library >> modules that already exist in other custodians. [ Though I can't tell >> exactly what's happening, I can see a lot of disk activity when I think I'm >> loading a 5KB servlet. ] Reasonably I would have expected that after >> loading/linking the first servlet, the libraries common to the servlets >> would be already in memory. But loading additional servlets is no quicker [ >> and causes a similar disk hit ] so clearly I don't understand what is >> happening internally with the custodians. >> >> If a Racket library is deliberately put into the servlet-namespace, does >> that streamline linking? >> > > Your assumption about the purpose of this is not correct. Anything in > the servlet-namespace will be shared between all servlets, and thus > not loaded per-servlet. > >>> My application so far is based on stateful servlets and AJAX ... stateful >>> mainly because it's easier for me to understand. Currently there is >>> little use of continuations, but some planned functionality will use them >>> extensively and it certainly would help if debugging didn't always mean >>> starting over setting up conditions in the application. >> >> This comment/question is related to questions 4 and 5 from the FAQ: >> >> http://docs.racket-lang.org/web-server/faq.html?q=servlet-namespace#%28part._update-servlets%29 >> >> >> That link leads to a "troubleshooting" page 8-). I didn't consider the >> issue to be a "problem" per se - I already knew that restarting a stateful >> servlet would lose saved state. Most of my existing servlets are one-shots >> that don't save any state, but they are written using the stateful language. >> Only a few use continuations and not extensively (so far). I was just >> thinking ahead to stuff that will need to use continuations more >> extensively. >> >> Thanks for putting up with my questions. >> George >> > > > > -- > Jay McCarthy > http://jeapostrophe.github.io > > "Wherefore, be not weary in well-doing, > for ye are laying the foundation of a great work. > And out of small things proceedeth that which is great." > - D&C 64:33 > > > End of users Digest, Vol 109, Issue 57 > ************************************** ____________________ Racket Users list: http://lists.racket-lang.org/users

