Ah yes. We agree. I presume that Zack is concerned with the normal circumstance of running a racket program from the command line, but I recognize that you could do lots of creative things that will behave properly.
Jay On Thursday, February 14, 2013, Robby Findler wrote: > That is also what I meant by code (well, I was speaking generally about > all bytecode). > > The point I'm making is that this is not a limitation of our runtime > system, it is just because you are imagining there are still references to > that bytecode. > > In the specific instance you mention below, the namespace holding onto > that module could become garbage. This happens in DrRacket a lot, for > example. > > > On Thu, Feb 14, 2013 at 7:45 AM, Jay McCarthy <[email protected]>wrote: > > When I say "code", I mean module top-level binding byte-code. There's > no way for Racket to remove > > (define (f x) (lambda (y) (printf "Gigantic string: ~a" (+ x y)))) > > at the top-level. The byte-code will always contain the gigantic > string. If you ever call f and get back something, that closure could > be collected, but not the source that generated it. > > Jay > > On Thu, Feb 14, 2013 at 6:37 AM, Robby Findler > <[email protected]> wrote: > > I'm pretty sure code is collected in (regular) Racket. Small numbers > aren't > > collected, true, but they also don't really take any space. Big numbers > are > > collected, too. (I'm not sure about interned symbols.) > > > > Robby > > > > > > On Thu, Feb 14, 2013 at 7:26 AM, Jay McCarthy <[email protected]> > > wrote: > >> > >> In the Web server language, all anonymous functions are turned into > >> top-level structures masquerading as functions where the fields are > >> their free variables. For instance: > >> > >> (define (f x) (lambda (y) (+ x y)) > >> > >> becomes, roughly, > >> > >> (struct a-lambda42 (x) > >> #:property prop:procedure > >> (lambda (the-structure y) > >> (define x (a-lambda42-x the-structure)) > >> (+ x y))) > >> (define (f x) (make-a-lambda42 x)) > >> > >> In your program, the expression > >> > >> (web-cell-shadow wc-anonymous (λ (x) 'more-distinctive-text)) > >> > >> becomes > >> > >> (struct a-lambda43 () #:property prop:procedure (lambda (s x) > >> 'more-distinctive-text)) > >> (web-cell-shadow wc-anonymous (make-a-lambda43)) > >> > >> Notice that the anonymous function has no fields because there are no > >> free variables. The distinctive text is not shown anywhere in the URL > >> because it is part of the code, not part of the data, of the closure. > >> > >> If you change the program slightly to > >> > >> (web-cell-shadow wc-anonymous > >> (let () (define y 'more-distinctive-text) > >> (λ (x) y))) > >> > >> then y is a free variable, so when you look at the URL: > >> > >> > >> > http://localhost:8000/;((%22c%22%20.%20%220((3)%204%20(((lib%20%5C%22web-server%2Flang%2Fabort-resume.rkt%5C%22)%20.%20%5C%22lifted.6%5C%22)%20((lib%20%5C%22web-server%2Flang%2Fweb-cells.rkt%5C%22)%20.%20deserialize-info:frame-v0)%20(%23%5C%22%2Ftmp%2Ft.rkt%5C%22%20.%20%5C%22lifted.1683%5C%22)%20(2%20.%20%5C%22lifted.1991%5C%22))%200%20()%20()%20(0%20(1%20(h%20-%20()%20(lifted.1485-0%20.%20this-is-a-song-about-Japan)%20(lifted.1521-1%202%20(b!%20.%20more-distinctive-text))))%20(c%20(v!%20(3)%20%23f%20%23f))))%22)) > >> > >> You see the distinctive text. > >> > >> As far as GC goes, code is not generally collected in Racket anyways. > >> Any data that is an intrinsic part of the program text (such as > >> literal symbols and numbers) will always be around in your program > >> whether you use #lang web-server or not. > >> > >> Jay > >> > >> > >> On Wed, Feb 13, 2013 at 8:34 PM, Galler <[email protected]> wrote: > >> > Good evening, > >> > > >> > I've been investigating lang web-server, performance and garbage > >> > collection > >> > > >> > I have a question > > -- Jay McCarthy <[email protected]> Assistant Professor / Brigham Young University http://faculty.cs.byu.edu/~jay "The glory of God is Intelligence" - D&C 93
____________________ Racket Users list: http://lists.racket-lang.org/users

