Summary

IR-transformer not implicitly renaming?

Metadata

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!"

Changes and comments

[2021-06-02 12:52:27 UTC] Idiomdrottning wrote:

I was thinking it was gonna say

Error: unbound variable: hey

[2021-06-02 12:57:37 UTC] Idiomdrottning wrote:

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)

[2021-06-02 12:57:53 UTC] Idiomdrottning changed status from new to closed

[2021-06-02 12:57:53 UTC] Idiomdrottning set resolution to invalid

[2021-06-02 12:58:26 UTC] Idiomdrottning changed status from closed to reopened

[2021-06-02 12:58:26 UTC] Idiomdrottning removed resolution invalid

[2021-06-02 13:24:36 UTC] Idiomdrottning wrote:

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"

[2021-06-02 13:38:35 UTC] Idiomdrottning set resolution to invalid

[2021-06-02 13:38:35 UTC] Idiomdrottning wrote:

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

[2021-06-02 13:38:35 UTC] Idiomdrottning changed status from reopened to closed

[2021-06-02 13:59:49 UTC] sjamaan wrote:

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.