[racket] handling curried functions in a 'define' macro
On 2014-02-15 20:42:06 -0500, Asumu Takikawa wrote:
> (define-syntax (my-define stx)
> (syntax-case stx ()
> [(_ . rst)
> (define-values (id rhs)
> (normalize-definition stx #'my-lambda))
> #'(define #,id #,rhs)]))
I should actually try the examples I write. Here's a version that should
work:
(require (for-syntax syntax/define))
;; silly lambda that just runs body twice
(define-syntax-rule (my-lambda (x ...) b)
(lambda (x ...) b b))
(define-syntax (my-define stx)
(syntax-case stx ()
[(_ . rst)
(begin
(define-values (id rhs)
(normalize-definition stx #'my-lambda))
#`(define #,id #,rhs))]))
(my-define (f x) (displayln x))
(f 3)
Cheers,
Asumu