[racket] hash-ref

From: Jos Koot (jos.koot at telefonica.net)
Date: Sun Jul 18 16:32:21 EDT 2010

Ha, that makes sense.
I had the (apparently wrong) idea that a thunk would be compiled to a ready
to use procedure and would be immediately available at run time.
Thanks. Jos 

> -----Original Message-----
> From: robby.findler at gmail.com 
> [mailto:robby.findler at gmail.com] On Behalf Of Robby Findler
> Sent: 18 July 2010 15:39
> To: Jos Koot
> Cc: plt-scheme
> Subject: Re: [racket] hash-ref
> 
> It is for performance reasons. Specifically you can avoid 
> creating the procedure over and over (if you're calling 
> hash-ref over and over).
> 
> Robby
> 
> On Sunday, July 18, 2010, Jos Koot <jos.koot at telefonica.net> wrote:
> >
> >
> >
> >
> >
> > (hash-ref
> > a-hash a-key a-value)
> > In the past
> > a-value was required to be a procedure.
> > Now it can
> > be anything.
> >
> > Nice.
> > Two caveats
> > though.
> > 1. If the
> > value of a-value happens to be a procedure to be stored, it may 
> > unintentionally be called.
> > 2. a-value
> > may be an expresssion that takes much computation. This 
> computation is 
> > repeated every time the hash-ref line is evaluated.
> >
> > Simply
> > helped of course: I make it a habbit always to write or to 
> have macros 
> > expand
> > to:
> > (hash-ref a-hash a-key (lambda ()
> > a-value))
> >
> > In short, I do not well understand the reason to relax the 
> contract of 
> > hash-ref and hash-ref!.
> > Jos
> >
> >
> >




Posted on the users mailing list.