This is the mail archive of the kawa@sourceware.org mailing list for the Kawa project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: proposed support for lazy values


On 06/06/2011 07:28 AM, Jamison Hope wrote:
On Jun 4, 2011, at 3:15 AM, Per Bothner wrote:

Could you try the attached patch? A review would be appreciated as well.

That works for me. Good catch with initializing result to something other than null. I suppose someone could still write a promise that evaluates to Location.UNBOUND, but that's probably unlikely enough to ignore. There's still a minor deficiency in print():

#|kawa:1|# (define my-promise (delay (throw (java.lang.Exception))))
#|kawa:2|# my-promise
#<promise - not forced yet>
#|kawa:3|# (force my-promise)
java.lang.Exception

I would argue that the print at line 4 should say something like
"#<promise - force threw a java.lang.Exception>" instead. How about the
attached update to your patch?

I took your suggestion, but added synchronization. See the attachment.


Note I also changed force to add an extra check after the apply0 call, to
match RnRS semantics for "nested" forcing.

Note also that after the grand plan calls for auto-force by display and the REPL;
at that point the change to print will primarily affect calls to write.
--
--Per Bothner
per@bothner.com http://per.bothner.com/

Attachment: Promise3.patch
Description: Text document


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]