[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Breaking hygiene with syntax-rules?
From: |
Walter Lewis |
Subject: |
Breaking hygiene with syntax-rules? |
Date: |
Thu, 10 Aug 2023 22:35:09 -0400 |
Hi guile,
Consider this program:
(define-syntax unhygienic
(syntax-rules ()
((_ the-pair fetch)
(begin
(define the-head (car the-pair))
(define (fetch) the-head)))))
(unhygienic '(1) fetch1)
(unhygienic '(2) fetch2)
(fetch1)
;; => 2
It seems that the second call to unhygienic shadows the previous
definition of the-head. I expected syntax-rules to generate fresh names
for it each time.
Is this expected, and if so, is there any way to generate an internal
definition using syntax-rules? For my case, I was writing a macro to
generate SRFI-9 record definitions, but I noticed some of the getters
and setters which I intended to be private were shadowing each other.
Best,
Walter
- Breaking hygiene with syntax-rules?,
Walter Lewis <=