ChezScheme icon indicating copy to clipboard operation
ChezScheme copied to clipboard

Error in tspl for make-variable-transformer

Open gwatt opened this issue 2 years ago • 1 comments

https://scheme.com/tspl4/syntax.html#./syntax:s42

The given example is missing set! in the syntax-case literal list:

(let ([ls (list 0)])
  (define-syntax a
    (make-variable-transformer
      (lambda (x)
        (syntax-case x ()
          [id (identifier? #'id) #'(car ls)]
          [(set! _ e) #'(set-car! ls e)]
          [(_ e ...) #'((car ls) e ...)]))))
  (let ([before a])
    (set! a 1)
    (list before a ls))) ⇒ (0 1 (1))

As-is, any form like (a _ _) will result in a set! form.

gwatt avatar Sep 25 '23 16:09 gwatt

Indeed! I wonder if @dybvig is still updating the errata?

Chez Scheme Version 10.1.0
Copyright 1984-2024 Cisco Systems, Inc.

> (define ls (list 0))
> (define-syntax a
        (make-variable-transformer
          (lambda (x)
            (syntax-case x ()
              [id (identifier? #'id) #'(car ls)]
              [(set! _ e) #'(set-car! ls e)]
              [(_ e ...) #'((car ls) e ...)]))))
> (a 'foo 'bar)
> ls
(bar)

mml avatar Dec 10 '24 20:12 mml