Re: [racket-users] MIT/Chicken/Chibi Scheme style ir-macro-transformer in Racket

2018-08-29 Thread Shu-Hung You
I should've been clear that the loop example was taken from the Chicken scheme wiki. Same for the while example mentioned in the email: https://wiki.call-cc.org/man/4/Macros#ir-macro-transformer Using the syntax->datum here would drop lexical information though; if the syntax object given to the

Re: [racket-users] MIT/Chicken/Chibi Scheme style ir-macro-transformer in Racket

2018-08-29 Thread t791bc via Racket Users
Thanks for the responses. In case anybody is interested, I came up with the following implementation. Since (at least in this simple implementation) there is an obvious symmetry between explicit renaming and implicit renaming I added the er-macro-transformer also. They seem to work correctly.

Re: [racket-users] MIT/Chicken/Chibi Scheme style ir-macro-transformer in Racket

2018-08-29 Thread Shu-Hung You
I think the following program illustrates the idea, though it doesn't really work: #lang racket (begin-for-syntax (define (syntax-pair->cons stx) (define datum (syntax-e stx)) (cond [(list? datum) (map syntax-pair->cons datum)] [(pair? datum) (cons

Re: [racket-users] MIT/Chicken/Chibi Scheme style ir-macro-transformer in Racket

2018-08-29 Thread Philip McGrath
For future reference, you should try the wonderful macro stepper in DrRacket, which shows you exactly how expansion happens. It can even handle buggy, non-terminating examples like the version of `test` you wrote. -Philip On Wed, Aug 29, 2018 at 7:20 AM Philip McGrath wrote: > I'm not familiar

Re: [racket-users] MIT/Chicken/Chibi Scheme style ir-macro-transformer in Racket

2018-08-29 Thread Philip McGrath
I'm not familiar with how `ir-macro-transformer` is supposed to work, but your macro is currently fails for essentially the same reason as: (define-syntax (diverge stx) stx The `expr` given to `test` is a syntactic list beginning with the identifier `test`, so including it in the output

[racket-users] MIT/Chicken/Chibi Scheme style ir-macro-transformer in Racket

2018-08-29 Thread t791bc via Racket Users
Hi, while syntax-case has some advantages, I was trying to implement a Chicken style ir-macro-transformer in Racket so that I can write macros that will run both on Racket and systems like Chicken/Chibi Scheme. My first attempt was as follows: (begin-for-syntax (require (for-syntax