[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: segfault in CVS HEAD
From: |
Dirk Herrmann |
Subject: |
Re: segfault in CVS HEAD |
Date: |
Sun, 20 Jun 2004 09:15:29 +0200 |
User-agent: |
Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.4.2) Gecko/20040220 |
Han-Wen Nienhuys wrote:
address@hidden writes:
> address@hidden writes:
>
>> byrd:~/usr/src/guile/libguile$ cat t.scm (defiaine blub (cons
>> (quote (1 . 2)) 2))
>>>
>> for some reason, GUILE unmemoizes the procedure during print; of
>> course, the expression is not memoized, since evaluation stops
>> after "defiaine". I've seen similar problems with invocations of
>> procedure-source on valid code.
Sorry for answering so late. The problem is due to some changes that I
had introduced.
I've implemented a kludge in CVS: the for loop now has a SCM_CONSP as
the condition. It produces incorrect output in the example that I
sent, but at least it doesn't crash.
I will fix it. Sorry again for the delay.
BTW,
why are vectors quoted in the unmemoize output? from
unmemoize_expression():
Short answer: To make the unmemoized output R5RS compliant.
Long answer, for everyone interested: According to R5RS, vector
constants must be quoted. The reason is the following:
#((1 + 2))
evaluates to
#((1 + 2))
rather than
#(3)
To make this behaviour more obvious, R5RS demands to write
'#((1 + 2))
Guile's executor does not need to see the quotes. That is, we strip away
the quotes during memoization since this gives a slight performance
improvement when dealing with vector constants. When unmemoizing the
code again, however, in order to produce syntactically correct
unmemoized code, the required quote is added again. Please compare the
following:
guile> (define (foo) #(1))
guile> (foo)
#(1)
guile> (procedure-source foo)
(lambda () (quote #(1)))
guile> (define (bar) '#(1))
guile> (bar)
#(1)
guile> (procedure-source bar)
(lambda () (quote #(1)))
Best regards
Dirk Herrmann