[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Chicken-janitors] #1362: A case when composing with ir-macro-transforme
From: |
Chicken Trac |
Subject: |
[Chicken-janitors] #1362: A case when composing with ir-macro-transformer |
Date: |
Wed, 12 Apr 2017 12:13:41 -0000 |
#1362: A case when composing with ir-macro-transformer
---------------------------------+--------------------------------
Reporter: megane | Owner:
Type: defect | Status: new
Priority: not urgent at all | Milestone: someday
Component: expander | Version: 4.12.0
Keywords: ir-macro-trasformer | Estimated difficulty:
---------------------------------+--------------------------------
I ran into this unexpected behaviour when using ir macros in ir macros. I
don't think this should happen:
(I have tested this with 4.12, not with 5. )
First macro:
{{{#!scheme
(define-syntax bind-pair
(ir-macro-transformer
(lambda (e i c)
(let* ((b (second e))
(exp (third e))
(body (drop e 3)))
`(let* ((x ,exp)
(,(first b) (car x))
(,(second b) (cdr x)))
,@body)))))
}}}
Testing:
{{{
(bind-pair (x y) (cons 1 2) (print y))
=> prints 2
}}}
Now a second macro using bind-pair:
{{{#!scheme
(define-syntax foo
(ir-macro-transformer
(lambda (e i c)
`(bind-pair (x y) (cons 'foo-car 'b) (print y)))))
}}}
Running (foo) gives the error:
Error: (cdr) bad argument type: foo-car
The expansion of (foo) looks like this:
{{{
;; (##core#let
;; ((x40 (cons42 (quote43 foo-car44) (quote43 b45))))
;; (##core#let
;; ((x40 (car48 x40)))
;; (##core#let ((y41 (cdr49 x40))) (##core#let () (print46 y41)))))
}}}
As you can see, the x in bind-pair and foo macros refer to the same
variable in the expansion. You can confirm this happens by changing the
x in foo to, say z.
--
Ticket URL: <https://bugs.call-cc.org/ticket/1362>
CHICKEN Scheme <https://www.call-cc.org/>
CHICKEN Scheme is a compiler for the Scheme programming language.
- [Chicken-janitors] #1362: A case when composing with ir-macro-transformer,
Chicken Trac <=