[plt-scheme] Expanding into this-expression-file-name

From: Noel Welsh (noelwelsh at yahoo.com)
Date: Tue Aug 22 09:41:32 EDT 2006

This works:

  ;; syntax this-expression-benchmark-log-file : () -> path
  (define-syntax (this-expression-benchmark-log-file stx)
    (syntax-case stx ()
      [(this-expression-benchmark-log-file)
       (with-syntax ([expr
                      (datum->syntax-object
                       stx
                       '(build-path
                         (this-expression-source-directory)
                         (string-append
                          (path->string
(this-expression-file-name))
                          ".benchmark-log"))
                       stx)])
         (syntax expr))]))

Don't know why -- I should think the context and lexical
information I supply are identical to my original code, but
obviously not.

N.

--- Noel Welsh <noelwelsh at yahoo.com> wrote:

> Hi all,
> 
> I have a macro that expands into
> this-expression-file-name.
>  I want the file name of the point of use, but I get the
> file name of the point of definition.  How do I get the
> macro to use the source information of the expansion
> point?
>  Current code below.
> 
> Thanks,
> Noel
> 
>   ;; syntax this-expression-benchmark-log-file : () ->
> path
>   (define-syntax (this-expression-benchmark-log-file stx)
>     (syntax-case stx ()
>       [(this-expression-benchmark-log-file)
>        ;; result is the same w/ just syntax instead of
> syntax/loc
>        (syntax/loc stx
>          (build-path
>           (this-expression-source-directory)
>           (string-append
>            (path->string (this-expression-file-name))
>            ".benchmark-log")))]))


Email: noelwelsh <at> yahoo <dot> com   noel <at> untyped <dot> com
AIM: noelhwelsh
Blogs: http://monospaced.blogspot.com/  http://www.untyped.com/untyping/

__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 


Posted on the users mailing list.