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.

Reply via email to