On Tue, Dec 07, 2010 at 12:46:29PM +0100, Peter Bex wrote: > R5RS explicitly mentions that nested quasiquote, unquote or > unquote-splicing calls in positions other than the head of a proper > list which contains two elements is undefined and can lead to > strange behaviour: > http://www.schemers.org/Documents/Standards/R5RS/HTML/r5rs-Z-H-7.html#%_sec_4.2.6
I checked R6RS, which extends the unquote/unquote-splicing syntaxes to allow for multiple arguments: http://www.r6rs.org/final/html/r6rs/r6rs-Z-H-14.html#node_sec_11.17 However, this is rather non-untuitive IMO: (let ((a 1) (b 2) (c 3)) (quasiquote ((unquote a b c)))) => (1 2 3) It's like unquote also sort-of splices its arguments into the containing list. In other words, it's identical to (let ((a 1) (b 2) (c 3)) (quasiquote ((unquote a) (unquote b) (unquote c)))) => (1 2 3) I find this _very_ weird. It feels as if they made (+ (values 1 2 3)) be identical to (+ 1 2 3) - sorry if that's a weird analogy, but it's exactly the same to my brain. Also, I'm unclear as to what happens when you leave off the outer parentheses: (let ((a 1) (b 2) (c 3)) (quasiquote (unquote a b c))) => ; error? If I interpret the spec correctly, it says the implementation should throw an error in this case. Testing with Racket confirms this. However, (quasiquote (quasiquote (unquote a b c))) is accepted by Racket, but that doesn't seem correct if I understand the spec. The quotation grammar in the spec doesn't make much sense to me though, so maybe someone can help out in explaining it? Quasiquote itself is not allowed to have multiple arguments, which is also a bit inconsistant (but logical). Racket does allow multiple nested arguments to quasiquotes. I haven't been able to test with any other r6rs Scheme because Racket is the only one available in pkgsrc and I'm not willing to mess around with building one from source. Extra data points would be appreciated if someone else reading this happens to have another r6 implementation at hand. Anyway, I'd like to add: Option 7: Do it the R6RS way. We'd have to flesh out what exactly happens when you do (quasiquote (quasiquote a b c)) or similar, and what happens when you pass multiple arguments to unquote in a non-list context. BTW, I also checked R7 but couldn't find anything related to quotation on their lists. Cheers, Peter -- http://sjamaan.ath.cx -- "The process of preparing programs for a digital computer is especially attractive, not only because it can be economically and scientifically rewarding, but also because it can be an aesthetic experience much like composing poetry or music." -- Donald Knuth _______________________________________________ Chicken-hackers mailing list Chicken-hackers@nongnu.org http://lists.nongnu.org/mailman/listinfo/chicken-hackers