Reputation: 6152
I'm designing a new language and would like to re-define the procedural form of define
but export the standard expression form as well. Is there a way I can do that? So far I have this code:
(define-syntax-rule (my-define (name args) body ...) ...)
(provide (rename-out [my-define define]) define)
but generates the error "identifier already provided (as a different binding) in: define"
Upvotes: 2
Views: 79
Reputation: 31147
Here is an example where my-define
handles both cases.
#lang racket
(provide (rename-out [my-define define]))
(require (for-syntax syntax/parse))
(define-syntax (my-define stx)
(syntax-parse stx
[(_define name:id e:expr) (syntax/loc stx (define name e))]
[(_define (name arg ...) body ...) (syntax/loc stx (define (name arg ...) body ...))]))
Upvotes: 2