[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Scheme-reports] ANN: first draft of R7RS small language available
- To: Andrzej <ndrwrdck@x>
- Subject: Re: [Scheme-reports] ANN: first draft of R7RS small language available
- From: Andre van Tonder <andre@x>
- Date: Tue, 3 May 2011 23:07:16 -0400 (EDT)
- Cc: scheme-reports <scheme-reports@x>
- In-reply-to: <BANLkTi=uH91qemtfe5tzCcAVUkpQcXCwJQ@mail.gmail.com>
- References: <BANLkTim=5TfhBkDHj9Pv_R+S99JrEeNojw@mail.gmail.com> <Pine.SOC.4.64.1105031030270.15666@oow.het.brown.edu> <BANLkTi=uH91qemtfe5tzCcAVUkpQcXCwJQ@mail.gmail.com>
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