[Top][All Lists]

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

Strange memoizing behavior

From: Matthias Koeppe
Subject: Strange memoizing behavior
Date: Thu, 17 Jan 2002 15:34:32 +0100
User-agent: Gnus/5.090004 (Oort Gnus v0.04) Emacs/21.1 (sparc-sun-solaris2.7)

If one passes a macro where a procedure is expected, this may seem to
work, but Guile's macro memoizing behavior will bite you afterwards.
I came across this problem today when a co-worker passed AND (a
PRIMITIVE-MACRO!) to the REDUCE procedure of (SRFI SRFI-1).  

It boils down to this:

    (define (foo procedure)
      (procedure 1 2 3))

    (foo list) ; returns (1 2 3)

    (foo and) ; Guile returns 3 and memoizes `procedure'=`and' in `foo'
              ; but it should signal an error (improper use of macro?)

    (foo list) ; now returns 3 too!

    (procedure-source foo) ; returns (lambda (procedure) (and 1 2 3))

This is a nightmare to debug because the bad (FOO AND) form succeeds
but destructively modifies the FOO procedure.  

Shouldn't Guile report that the (FOO AND) form is bad?

This is Guile 1.5.4, in case it matters.

Matthias K철ppe --

reply via email to

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