[plt-scheme] preserving the lack of an inferred name

From: Eli Barzilay (eli at barzilay.org)
Date: Fri Jun 18 18:49:10 EDT 2004

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)

          ((lambda (x) (x x)) (lambda (x) (x x)))          Eli Barzilay:
                  http://www.barzilay.org/                 Maze is Life!

Posted on the users mailing list.