unofficial mirror of guile-user@gnu.org 
 help / color / mirror / Atom feed
* Breaking hygiene with syntax-rules?
@ 2023-08-11  2:35 Walter Lewis via General Guile related discussions
  2023-08-11  5:07 ` Dr. Arne Babenhauserheide
  2023-08-11  8:00 ` Jean Abou Samra
  0 siblings, 2 replies; 14+ messages in thread
From: Walter Lewis via General Guile related discussions @ 2023-08-11  2:35 UTC (permalink / raw)
  To: guile-user

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


^ permalink raw reply	[flat|nested] 14+ messages in thread

end of thread, other threads:[~2023-08-14 19:26 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-08-11  2:35 Breaking hygiene with syntax-rules? Walter Lewis via General Guile related discussions
2023-08-11  5:07 ` Dr. Arne Babenhauserheide
2023-08-11  8:00 ` Jean Abou Samra
2023-08-11  8:33   ` Dr. Arne Babenhauserheide
2023-08-11 23:57     ` Jean Abou Samra
2023-08-12  5:57       ` Dr. Arne Babenhauserheide
2023-08-11 13:34   ` Walter Lewis via General Guile related discussions
2023-08-11 22:50     ` Walter Lewis via General Guile related discussions
2023-08-11 23:55       ` Jean Abou Samra
2023-08-11 23:57         ` Jean Abou Samra
2023-08-12  0:19           ` Walter Lewis
2023-08-12  0:58             ` Jean Abou Samra
2023-08-12  5:59             ` Dr. Arne Babenhauserheide
2023-08-14 19:26               ` Thompson, David

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).