guile-user
[Top][All Lists]
Advanced

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

Re: perplexing syntax-rules bug


From: Panicz Maciej Godek
Subject: Re: perplexing syntax-rules bug
Date: Sat, 20 Dec 2014 16:02:49 +0100

2014-12-20 8:39 GMT+01:00 Marco Maggi <address@hidden>:

The  problem  is  that  ASSQ-SET!  mutates the  result  of  the  literal
_expression_:

   '((name . <name>) (title . #f))

this problem is not related to SYNTAX-RULES.  The form:

   '((name . <name>) (title . #f))

is a  "literal _expression_", it  is an  _expression_ that evaluates  to the
datum:

   ((name . <name>) (title . #f))

To be precise, in the particular context of the macro definition, <name> is a macro parameter, so the assoc is not a literal, but a form that will get expanded to a literal during macro expansion. In particular, it should get expanded to

'((name . one) (title . #f))

from the first usage, and

'((name . two) (title . #f))

from the second usage.

By the way, I don't know guile internals, but I think the optimization (i.e. the assumption that both literal objects can be considered a single object) happens during compilation:

if you evaluate the form

(begin

  (sect one (title "Section One"))

  (sect two (title "Section Two")))


then you'll get the aforementioned unexpected behaviour, but if you evaluate each macro separately, everything will remain to behave properly.

So I don't think that any additional bit would be needed to mark whether an object is mutable or immutable: the compiler could check if any mutating procedure is called on an object before it considers it to be eq? with another equal? object from the context of an _expression_.


reply via email to

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