Opened 3 years ago

Closed 3 years ago

Last modified 3 years ago

#1760 closed defect (invalid)

IR-transformer not implicitly renaming?

Reported by: Idiomdrottning Owned by:
Priority: major Milestone: someday
Component: unknown Version: 5.2.0
Keywords: Cc:
Estimated difficulty:

Description

Is this by design or borked?

(define-syntax a-test

(ir-macro-transformer

(lambda (e i c)

'(define hey '(print "I said hey!")))))

(a-test)
hey

Prints "I said hey!"

Change History (7)

comment:1 Changed 3 years ago by Idiomdrottning

I was thinking it was gonna say

Error: unbound variable: hey

comment:2 Changed 3 years ago by Idiomdrottning

Oh, ok, I see. It only renames them inside of the macro.

(define-syntax maif

(ir-macro-transformer

(lambda (e i c)

`(let ((it ,(cadr e)))

(if it ,(caddr e) ,(cadddr e))))))

(maif (zero? 0) it 'no)

comment:3 Changed 3 years ago by Idiomdrottning

Resolution: invalid
Status: newclosed

comment:4 Changed 3 years ago by Idiomdrottning

Resolution: invalid
Status: closedreopened

comment:5 Changed 3 years ago by Idiomdrottning

OK I guess this is just normal.

(define-syntax stest

(syntax-rules ()

((stest)

(define (heyo) (print "Heyo!")))))

(stest)
(heyo)

So weird!
I thought this was "unhygienic"

comment:6 Changed 3 years ago by Idiomdrottning

Resolution: invalid
Status: reopenedclosed

Went back over and removed some unnecessary injects from my code!

comment:7 Changed 3 years ago by sjamaan

This is actually a corner case of ER macros, too. It's unspecified what should happen if you rename an identifier at toplevel. Currently, CHICKEN just strips the renaming, but this may change in the future, so it's better to leave those "unnecessary" injects, IMO.

Note: See TracTickets for help on using tickets.