Scheme language standardization process
On Wed, 4 May 2011, Andrzej wrote:
On Tue, May 3, 2011 at 11:35 PM, Andre van Tonder <andre@x> wrote:(define-syntax convert-to-boolean (syntax-rules () ((_ exp) (cond (exp #t) (else #f))))) (let ((else #f)) (convert-to-boolean else)) What answer should he get? What answer would he get in your implementation?My implementation will return #f here (that is once I have macro expansion in place) because it expands to:(let ((else #f)) (cond (else #t) (else #f))) => #f
I am not sure, but I think this might be a syntax error, given that the spec says:
The LAST <clause> may be an ``else clause,''Be that as it may, let me give another example. I am pretty sure that the the spec requires the following to evaluate to 1.
(define-syntax nonfalse-identity
(syntax-rules ()
((_ x)
(cond (x => (lambda (x) x))))))
(let ((else 1))
(nonfalse-identity else)) ====> 1
but I think your implementation will give the wrong result here (or an error).
Here is anotehr example, which evaluates a given expression (in case it has
side effects) and returns 1. It is a silly way of doing this, but there is no
doubt that the spec requires the answer to be 1.
(define-syntax map-to-identity
(syntax-rules ()
((_ exp)
(cond (#t exp 1)))))
(let ((=> 0))
(map-to-identity =>)) ======> 1
Again, I believe your implementation will return the wrong answer (or an error)._______________________________________________ Scheme-reports mailing list Scheme-reports@x http://lists.scheme-reports.org/cgi-bin/mailman/listinfo/scheme-reports