chicken-hackers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Chicken-hackers] [PATCH] R7RS delay/force/delay-force


From: John Cowan
Subject: Re: [Chicken-hackers] [PATCH] R7RS delay/force/delay-force
Date: Sat, 2 Nov 2013 01:21:25 -0400
User-agent: Mutt/1.5.20 (2009-06-14)

Jörg F. Wittenberger scripsit:

> Rather uncontroversial: r7rs says "the result of a delayed
> expression returning multiple values is unspecified". Hence it's OK
> to actually return multiple values (as I'd prefer r7rs should have
> explicitely required). The downside is that a portable program must
> not depend on this to work.

The reason we didn't require this is that in order to cache the multiple
values, in practice the implementation would have to put them into a
data structure, so the user might just as well delay the data structure
explicitly. So instead of (delay (exact-integer-sqrt n)), you can instead
do (delay (call-with-values (lambda () (exact-integer-sqrt n)) list).
This may be a bit more messy, but it didn't seem worth complicating the
implementation for what is expected to be a rare case.

> It specifies "if it is forced a second time, the previously computed
> value is returned". This _could_ (and IMHO _should_) be understood
> as if the delayed expression must only ever be evaluated once.

That's the most plausible interpretation, yes.  But there are at
least two issues: re-entrancy via call/cc and via threads (which
in some implementations may be the same).  We left that open,
because it's not clear what the Right Thing is.

-- 
John Cowan  address@hidden  http://ccil.org/~cowan
The penguin geeks is happy / As under the waves they lark
The closed-source geeks ain't happy / They sad cause they in the dark
But geeks in the dark is lucky / They in for a worser treat
One day when the Borg go belly-up / Guess who wind up on the street.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]