On Dec 19, 2014, at 11:39 PM, Marco Maggi <marco.maggi-i...@poste.it> wrote:

> Wette, Matthew R (3441) wrote:
> 
>> 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
> 
> (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)))))
> 
> The  problem  is  that  ASSQ-SET!  mutates the  result  of  the  literal
> expression:
> 
>   '((name . <name>) (title . #f))
> 
> 
>  To solve the problem you have to replace:
> 
>   '((name . <name>) (title . #f))
> 
> with:
> 
>   (list (cons 'name <name>) (cons 'title #f))
> 

OK.  Thanks.   I'm guessing list-copy would be another option: (sval (list-copy 
'((a . 1) (b . 2)))

Matt


Reply via email to