guile-user
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Problem with cond macro.


From: Panagiotis Vossos
Subject: Re: Problem with cond macro.
Date: Tue, 16 Apr 2002 12:45:40 +0300
User-agent: Gnus/5.0808 (Gnus v5.8.8) Emacs/20.7

address@hidden (Julian v. Bock) writes:

> >>>>> "PV" == Panagiotis Vossos <address@hidden> writes:
> 
> PV> Ok, I just started studying macros, so I might be missing
> PV> something obvious, but the following example from r5rs doesn't
> PV> work correctly with guile:
> 
> guile> (version)
> PV> "1.5.6"
> guile> (let ((=> #f))
> PV>    (cond (#t => 'ok))) standard input:3:10: In expression (cond
> PV> (#t => #)): standard input:3:10: Wrong type to apply: ok ABORT:
> PV> (misc-error)
> 
> This works only if cond is implemented as a R5RS macro. This is not
> guaranteed by the standard though.

Maybe, but I used a r5rs macro to implement 'my-cond' and it still
didn't work correctly.  Here's a simpler case:

(define-syntax foo
  (syntax-rules (=>)
    ((_ a => b) b)
    ((_ a b c) (+ a b c))))

(foo 10 => 20)
(let ((=> 10))
  (foo 10 => 20))

As I understand it, the first use of the macro should return 20 and
the second 40 (SCM and s48 indeed return these values).  But guile
fails on the second one and returns 20.  Here's the exact session:

guile> (use-modules (ice-9 syncase))
guile> (version)
"1.5.6"
guile> (define-syntax foo
         (syntax-rules (=>)
           ((_ a => b) b)
           ((_ a b c) (+ a b c))))

(foo 10 => 20)
(let ((=> 10))
  (foo 10 => 20))
guile> 20
guile> 20

What am I doing wrong ?

panagiotis



reply via email to

[Prev in Thread] Current Thread [Next in Thread]