From: Panicz Maciej Godek <godek.maciek@gmail.com>
To: "Wette, Matthew R (3441)" <matthew.r.wette@jpl.nasa.gov>
Cc: "guile-user@gnu.org" <guile-user@gnu.org>
Subject: Re: perplexing syntax-rules bug
Date: Sat, 20 Dec 2014 00:11:45 +0100 [thread overview]
Message-ID: <CAMFYt2av6Xex36DEKYoFaGuXMq9xaepwWMmPjdD=C39M4ixaVQ@mail.gmail.com> (raw)
In-Reply-To: <D0B9C71A.F152%Matthew.R.Wette@jpl.nasa.gov>
[-- Attachment #1: Type: text/plain, Size: 1779 bytes --]
It doesn't seem to be a bug in syntax-rules. It seems to appear whenever
two consecutive let forms are used with an assoc list argument which starts
with identical elements:
(begin
(let ((l '((a . X)(b . Y)(c . 7))))
(assoc-set! l 'b 'Z))
(let ((l '((a . X)(b . Y))))
l))
===> ((a . X) (b . Z))
It is likely that the compiler assumes that both lists can be represented
using the same storage, because it doesn't notice that the first object
gets mutated.
This qualifies for a serious bug report, but if you wish to get a quick
workaround, you can do it like this:
(define-syntax sect
(syntax-rules ()
((sect <name> <expr> ...)
(let* ((sval* '(skip ((name . <name>) (title . #f))))
(sval (cdr sval*)))
(format #t "new sect: ~a\n" (quote <name>))
(format #t " sval= ~a\n\n" sval)
(assq-set! sval 'title "ABC")
(values)))))
Thanks®ards
2014-12-19 21:14 GMT+01:00 Wette, Matthew R (3441) <
matthew.r.wette@jpl.nasa.gov>:
> Sorry to bug, I can't figure out why "sval" in the second evaluation of
> "sect" is bound to the "sval" from the first evaluation of "sect". Anyone
> understand? This is guile 2.0.11. -- Matt
>
> ;; bug_syntax.scm
>
>
> (define-syntax sect
>
> (syntax-rules ()
>
> ((sect <name> <expr> ...)
>
> (let ((sval '((name . <name>) (title . #f))))
>
> (format #t "new sect: ~a\n" (quote <name>))
>
> (format #t " sval= ~a\n\n" sval)
>
> (assq-set! sval 'title "ABC")
>
> (values)))))
>
>
> (sect one (title "Section One"))
>
> (sect two (title "Section Two"))
>
> > (load "bug_syntax.scm")
>
> new sect: one
>
> sval= ((name . one) (title . #f))
>
>
> new sect: two
>
> sval= ((name . two) (title . ABC))
>
>
>
>
>
[-- Attachment #2: Type: text/html, Size: 4825 bytes --]
next prev parent reply other threads:[~2014-12-19 23:11 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-12-19 20:14 perplexing syntax-rules bug Wette, Matthew R (3441)
2014-12-19 23:11 ` Panicz Maciej Godek [this message]
2014-12-20 7:39 ` Marco Maggi
2014-12-20 10:29 ` Thien-Thi Nguyen
2014-12-20 14:37 ` Wette, Matthew R (3441)
2014-12-20 15:02 ` Wette, Matthew R (3441)
2014-12-20 15:02 ` Panicz Maciej Godek
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: https://www.gnu.org/software/guile/
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='CAMFYt2av6Xex36DEKYoFaGuXMq9xaepwWMmPjdD=C39M4ixaVQ@mail.gmail.com' \
--to=godek.maciek@gmail.com \
--cc=guile-user@gnu.org \
--cc=matthew.r.wette@jpl.nasa.gov \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).