[plt-scheme] preserving the lack of an inferred name
On Jun 18, Doug Orleans wrote:
> The problem is if there is no inferred name, i.e. `syntax-local-name'
> returns #f, the procedure will be named `foo':
>
> > (keep-name (lambda () 1))
> foo
> #<procedure:foo>
>
> Is there a way to keep the procedure unnamed, so that a name will be
> constructed from its location like usual?
>
> > (lambda () 1)
> #<procedure:STDIN::1424>
I don't see a way to do that, but you could do something like:
(define-syntax (keep-name stx)
(syntax-case stx ()
((_ x)
(let ((name (syntax-local-name)))
(with-syntax ((x (syntax-property #'x 'inferred-name name))
(name name))
(syntax/loc stx
(begin (display 'name)
(newline)
x)))))))
--
((lambda (x) (x x)) (lambda (x) (x x))) Eli Barzilay:
http://www.barzilay.org/ Maze is Life!