From: Derek U. <Der...@on...> - 2002-09-10 19:28:57
|
Here are 10 tests, for a reasonable value of "assert-equal?": (assert-equal? (values 3) 3) (assert-equal? ((lambda () (values 1 2) 3)) 3) (assert-equal? (call-with-values (lambda () 3) (lambda (x) x)) 3) (assert-equal? (call-with-values (lambda () (values)) (lambda () 3)) 3) (assert-equal? (call-with-values (lambda () (values 3)) (lambda (x) x)) 3) (assert-equal? (call-with-values (lambda () (values 1 2)) (lambda (a b) (vector b a))) '#(2 1)) (assert-equal? (call-with-values (lambda () (values)) (lambda args (list->vector args))) '#()) (assert-equal? (call-with-values (lambda () (values 1)) (lambda args (list->vector args))) '#(1)) (assert-equal? (call-with-values (lambda () (values 1 2)) (lambda args (list->vector args))) '#(1 2)) (assert-equal? (.toString (values 1 2)) (string-append "1" (System.getProperty "line.separator") "2")) I don't know of any single book that describes "syntax-rules" *well*. Myself, I've picked it up in bits and pieces over the years. Who is the target audience? Derek -----Original Message----- From: Ken Anderson [mailto:kan...@bb...] Sent: Monday, September 09, 2002 7:22 PM To: Derek Upham; 'jsc...@li...' Subject: Re: [Jscheme-devel] Implementation of "values", "call-with-values" Derek, This is cool. Do you mean my completely lame implementation of values as list wasn't good enough? BTW, I'm an old Lisper, so i understand "hurt yourself macros" from Common Lisp. Paul Graham's book, http://www.paulgraham.com/onlisp.html has 14 chapters on them. I don't know of a book that teaches Scheme's hygienic macro system. I've tried to write one, but it turned out to be too hard. Any pointers in this area would be helpful. In the spirit of Extereme Programming, could you provide several (4?) tests i could use to be sure your refactoring doesn't break anything else? Thanks! k At 09:17 PM 9/9/2002, Derek Upham wrote: >The URL > > http://www.serv.net/~sand/jscheme-values/ > >contains a directory of files that implement R5RS "values" and >"call-with-values" in JScheme (based on the CVS tree), replacing the >implementation in the EOPL2 support code. These are the complete files, not >patch files. > >The implementation uses the typical hack of creating an object that bundles >all the return values; "call-with-values" knows how to unpack the object. >This makes it possible to run illegal code, e.g., > > (define foo (values 1 2 3)) > >The implementation handles the weirdnesses and edge cases that I know about: > > * "(values X)" returns "X", not a values object > > * "(values)" is supported, and can be passed to continuations that take no >arguments. > > * It is always legal to pass zero values or more than one value to >continuations that ignore their arguments (such as the continuations of >non-tail expressions inside a "lambda" body). > >The printed representation of a "values" object is the representation of all >the child objects, separated by newlines. The REPL adds a newline on the >end, which means that "(values)" displays as a blank line. It may be useful >to tweak the REPL to avoid that as a special case. > >Derek > >-- >Derek Upham >Senior Software Engineer >Ontain >1750 112th Ave NE, Suite C-245 >Bellevue, WA 98004-3727 >Tel: 425-460-1886 >der...@on... > > >------------------------------------------------------- >This sf.net email is sponsored by: OSDN - Tired of that same old >cell phone? Get a new here for FREE! >https://www.inphonic.com/r.asp?r=sourceforge1&refcode1=vs3390 >_______________________________________________ >Jscheme-devel mailing list >Jsc...@li... >https://lists.sourceforge.net/lists/listinfo/jscheme-devel |