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. <div><br>
</div><div>Jay<span></span></div><div><br>On Thursday, February 14, 2013, Robby Findler wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">That is also what I meant by code (well, I was speaking generally about all bytecode). <div>
<br></div><div>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.</div>
<div><br></div><div>In the specific instance you mention below, the namespace holding onto that module could become garbage. This happens in DrRacket a lot, for example.</div></div><div><br><br><div>
On Thu, Feb 14, 2013 at 7:45 AM, Jay McCarthy <span dir="ltr"><<a>jay.mccarthy@gmail.com</a>></span> wrote:<br><blockquote style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
When I say "code", I mean module top-level binding byte-code. There's<br>
no way for Racket to remove<br>
<br>
(define (f x) (lambda (y) (printf "Gigantic string: ~a" (+ x y))))<br>
<br>
at the top-level. The byte-code will always contain the gigantic<br>
string. If you ever call f and get back something, that closure could<br>
be collected, but not the source that generated it.<br>
<span><font color="#888888"><br>
Jay<br>
</font></span><div><div><br>
On Thu, Feb 14, 2013 at 6:37 AM, Robby Findler<br>
<<a>robby@eecs.northwestern.edu</a>> wrote:<br>
> I'm pretty sure code is collected in (regular) Racket. Small numbers aren't<br>
> collected, true, but they also don't really take any space. Big numbers are<br>
> collected, too. (I'm not sure about interned symbols.)<br>
><br>
> Robby<br>
><br>
><br>
> On Thu, Feb 14, 2013 at 7:26 AM, Jay McCarthy <<a>jay.mccarthy@gmail.com</a>><br>
> wrote:<br>
>><br>
>> In the Web server language, all anonymous functions are turned into<br>
>> top-level structures masquerading as functions where the fields are<br>
>> their free variables. For instance:<br>
>><br>
>> (define (f x) (lambda (y) (+ x y))<br>
>><br>
>> becomes, roughly,<br>
>><br>
>> (struct a-lambda42 (x)<br>
>> #:property prop:procedure<br>
>> (lambda (the-structure y)<br>
>> (define x (a-lambda42-x the-structure))<br>
>> (+ x y)))<br>
>> (define (f x) (make-a-lambda42 x))<br>
>><br>
>> In your program, the expression<br>
>><br>
>> (web-cell-shadow wc-anonymous (λ (x) 'more-distinctive-text))<br>
>><br>
>> becomes<br>
>><br>
>> (struct a-lambda43 () #:property prop:procedure (lambda (s x)<br>
>> 'more-distinctive-text))<br>
>> (web-cell-shadow wc-anonymous (make-a-lambda43))<br>
>><br>
>> Notice that the anonymous function has no fields because there are no<br>
>> free variables. The distinctive text is not shown anywhere in the URL<br>
>> because it is part of the code, not part of the data, of the closure.<br>
>><br>
>> If you change the program slightly to<br>
>><br>
>> (web-cell-shadow wc-anonymous<br>
>> (let () (define y 'more-distinctive-text)<br>
>> (λ (x) y)))<br>
>><br>
>> then y is a free variable, so when you look at the URL:<br>
>><br>
>><br>
>> <a href="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))" target="_blank">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))</a><br>
>><br>
>> You see the distinctive text.<br>
>><br>
>> As far as GC goes, code is not generally collected in Racket anyways.<br>
>> Any data that is an intrinsic part of the program text (such as<br>
>> literal symbols and numbers) will always be around in your program<br>
>> whether you use #lang web-server or not.<br>
>><br>
>> Jay<br>
>><br>
>><br>
>> On Wed, Feb 13, 2013 at 8:34 PM, Galler <<a>lzgaller@optonline.net</a>> wrote:<br>
>> > Good evening,<br>
>> ><br>
>> > I've been investigating lang web-server, performance and garbage<br>
>> > collection<br>
>> ><br>
>> > I have a question </div></div></blockquote></div></div></blockquote></div><br><br>-- <br>Jay McCarthy <<a href="mailto:jay@cs.byu.edu" target="_blank">jay@cs.byu.edu</a>><br>Assistant Professor / Brigham Young University<br>
<a href="http://faculty.cs.byu.edu/~jay" target="_blank">http://faculty.cs.byu.edu/~jay</a><br><br>"The glory of God is Intelligence" - D&C 93<br>