racket/collects/math/scribblings/rename-defines.rkt
Neil Toronto 3670916a11 Initial commit for `math/array' documentation; about 65% finished
Replaced pointwise operators with macros that expand to applications of `array-map'; allows more precise return types and reduces compilation time

Changed literal array syntax to use #() to delimit rows instead of [] (still suggest using square parens, though)

Minor refactoring

Fixed a macro so that the only problem with "array-tests.rkt" now is that typed/rackunit is b0rked
2012-11-24 22:13:24 -07:00

20 lines
606 B
Racket

#lang racket/base
(require (for-syntax racket/base)
(only-in typed/racket/base define:))
(provide rename-defines)
(define-syntax (rename-defines stx)
(syntax-case stx ()
[(_ e)
(let ([expanded (local-expand #'e (syntax-local-context) #f)])
(syntax-case expanded (define-values)
[(define-values (x ...) expr)
(with-syntax ([(y ...) (generate-temporaries #'(x ...))])
(syntax/loc stx
(begin
(define-syntax x (make-rename-transformer #'y)) ...
(define-values (y ...) expr))))]
[_ #'e]))]))