Cool.  Thank you, Robby and Matthias.


On Fri, Oct 13, 2017 at 9:50 PM, Robby Findler
<ro...@eecs.northwestern.edu> wrote:
> If you want to know what the current racket does (not what the
> chez-based one does), then you can "raco make x.rkt" and then "raco
> decompile x.rkt" to see what is going on.
>
> In the cod quoted below, no closures are allocated because all of the
> functions bar, baz, and jaz are eliminated before runtime.
>
> The current compiler doesn't try to do anything with set!, so if you
> changed the program to this one:
>
> #lang racket
>
> (define (foo.1 x)
>   (define (bar) x)
>   (set! bar bar)
>   (bar))
>
> (define (foo.2 x)
>   (define (baz) 8)
>   (define (jaz) x)
>   (set! baz baz)
>   (set! jaz jaz)
>   (println (jaz))
>   (baz))
>
>
> you will see some lambda expressions survive.
>
> Of course, this may not be a bad thing, depending on what the actual
> application itself is doing. And it may be the case that some of those
> with empty closures aren't allocated, depending on various factors.
>
> Robby
>
>
> On Fri, Oct 13, 2017 at 8:19 PM, David Storrs <david.sto...@gmail.com> wrote:
>> On Fri, Oct 13, 2017 at 2:57 PM, Matthias Felleisen
>> <matth...@ccs.neu.edu> wrote:
>>>
>>>> On Oct 13, 2017, at 2:55 PM, David Storrs <david.sto...@gmail.com> wrote:
>>>>
>>>> On Fri, Oct 13, 2017 at 2:50 PM, David Storrs <david.sto...@gmail.com> 
>>>> wrote:
>>>>> Coming from a Perl background, I've long had a convention of naming
>>>>> private functions with a leading underscore, e.g. _do-the-thing.  Is
>>>>> there a standard Racket convention for this and, if so, what is it?
>>>>
>>>> Addendum:  I know that I can define functions inside the function for
>>>> which they are the helper, but my understanding is that if I do that
>>>> then the helper function is recompiled every time the parent function
>>>> is executed.
>>>>
>>>> (define (flurble args)
>>>>   (define (helper-func) ...do stuff...)
>>>>   (helper-func ...))
>>>>
>>>> (for ((i 10000))
>>>>  (flurble i)) ; helper-func will be built 10,000 times, right?
>>>
>>>
>>> No it isn’t recompiled. But the run-time may allocate a closure a second 
>>> time.
>>> Lambda lifting and similar techniques should avoid this but not necessarily 
>>> in
>>> the current compiler.
>>
>>
>> (define (foo x)
>>     (for ((i 10000))
>>         (define (bar) x)
>>         (bar)))
>>
>> So bar will be allocated 10,000 times in the above?  How about baz and
>> jaz in the below?
>>
>>
>> (define (foo x)
>>   (define (baz) 8)
>>   (define (jaz) x)
>>   (println (jaz))
>>   (baz))
>>
>> (for ((i 10000))
>>   (foo 7))
>>
>> --
>> You received this message because you are subscribed to the Google Groups 
>> "Racket Users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to racket-users+unsubscr...@googlegroups.com.
>> For more options, visit https://groups.google.com/d/optout.

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to