set-cdr! does not work

Issue #167 wontfix
Tang Chenglong created an issue

When I modify cdr of a list, set-cdr! does not work for me, and throw an exception.

I tried on both Windows 7 and Freebsd 10, 0.6.10 and 0.6.6 respectively.

Attached please find.

Comments (4)

  1. Takashi Kato repo owner

    Thank you for the report!

    The behaviour is intentional. Your definition of a is literal list ('(a)) and modifying such expressions is an error both R6RS and R7RS. Sagittarius follows the 'Should' behaviour described in R6RS which is raising &assertion. So this won't be fixed.

    The easiest way to avoid this error is the following:

    (import (rnrs) (rnrs mutable-pairs))
    (define a `(a)) ;; using quasiquote creates non literal list
    (set-cdr! a 'b)
    
  2. Tang Chenglong reporter

    Yes, you are right. I bypass it by

    (define a (list 'a))
    (set-cdr! a 'b)
    

    Thanks for your work!

  3. Log in to comment