This is the mail archive of the guile@sourceware.cygnus.com mailing list for the Guile project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: Strange behavior in a catch with (and) and (or)


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)))))

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]