This is the mail archive of the
guile@sourceware.cygnus.com
mailing list for the Guile project.
Re: Strange behavior in a catch with (and) and (or)
- To: Guile Mailing List <guile at sourceware dot cygnus dot com>
- Subject: Re: Strange behavior in a catch with (and) and (or)
- From: Kalle Olavi Niemitalo <tosi at stekt dot oulu dot fi>
- Date: 02 Mar 2000 16:52:26 +0200
- References: <Pine.LNX.4.21.0003011430240.23749-100000@europa.tellme.com>
This happens even without catch:
guile> (define (nullcase fn) (fn))
guile> (nullcase *)
1
guile> (nullcase and)
#t
guile> (nullcase *)
#t
guile> (version)
"1.3.4"
I don't know much about Guile internals, but I suppose that when
a macro is used in a function, Guile expands it only once and
stores the expanded form in the function. (This is called
memoization, right?)
I think it is wrong to call (nullcase and) in the first place,
because R5RS defines (and <test1> ...) as syntax -- you are not
supposed to take the value of AND. Guile allows that, but it
could as well signal an error like MzScheme does. There could be
a different syntax such as (local-syntax <symbol>) for extracting
the #<macro 4019a810> value if anyone needs it.
If you need to use something like AND here, you could define an
AND-FUNCTION which evaluates all arguments:
(define (and-function . args)
(or (null? args)
(and (car args)
(apply and-function (cdr args)))))