7.7
Static Renaming
(require static-rename) | package: static-rename-lib |
syntax
(static-rename name-id expr)
Equivalent to expr, but adjusts the statically inferred name for expr so that
(syntax-local-name) produces 'name-id while expanding expr. This allows
adjusting the names of things like procedures, which infer their runtime names based on static
information. Unlike procedure-rename, however, static-rename does not introduce any
additional runtime cost.
For more information, see Inferred Value Names.
Examples:
> (define f (λ (x) x)) > f #<procedure:f>
> (define g (static-rename renamed (λ (x) x))) > g #<procedure:renamed>
syntax
(define/renamed name-id id expr)
(define/renamed name-id (head args) body ...+)
head = id | (head args) args = arg ... | arg ... . rest-id arg = arg-id | [arg-id default-expr] | keyword arg-id | keyword [arg-id default-expr]
Defines a binding, just like define, but expr is statically renamed using
static-rename. Also like define, define/renamed is a shorthand form for
defining a function, which will use name-id for the runtime name produced by
object-name.
Examples:
> (define/renamed bar (foo x) (* 2 x)) > (foo 3) 6
> foo #<procedure:bar>
> (object-name foo) 'bar