[gambit-list] Promises & lazy thunks

Marc Feeley feeley at iro.umontreal.ca
Mon Apr 29 14:54:36 EDT 2013


On 2013-04-29, at 2:35 PM, Bradley Lucier <lucier at math.purdue.edu> wrote:

> On 04/29/2013 01:48 PM, Jason Felice wrote:
>> I was wondering if anyone's thought about doing this.  Also, if it's 
>> really as hard as making every primitive (except, course, promise?, 
>> promise-forced? and friends) check and force every parameter, or if 
>> there are any neat implementation tricks, especially if there's 
>> something which can be used in gambit (like error-handler, but that 
>> seems gross.  Also, incomplete and messy).
> 
> Try configuring gambit with "--enable-auto-forcing".  I've never tried 
> it, and I don't know whether it works.

Indeed Gambit can be configured so that strict primitives do auto-forcing of promises.  Just recompile Gambit with:

./configure --enable-auto-forcing
make bootclean
make

Then you'll be able to do this:

% gsi/gsi
Gambit v4.6.7

> (define a (delay (begin (pp 'forcing-a) 11)))
> (define b (delay (begin (pp 'forcing-b) 22)))
> (+ a b)
forcing-a
forcing-b
33
> (+ a b)
33

I just double-checked that it works.

Marc




More information about the Gambit-list mailing list