added this-expression-file-name

original commit: 106388724f571e96062423fed9ec65e9aeda3ccd
This commit is contained in:
Eli Barzilay 2005-03-18 20:35:57 +00:00
parent 1e3fd3bb9a
commit d3eb73d989

View File

@ -36,6 +36,7 @@
namespace-defined?
this-expression-source-directory
this-expression-file-name
define-syntax-set
hash-table
@ -466,6 +467,14 @@
(with-syntax ([d (if (bytes? dir) dir (path->bytes dir))])
(syntax (bytes->path d)))))]))
(define-syntax (this-expression-file-name stx)
(syntax-case stx ()
[(_)
(let* ([f (syntax-source stx)]
[f (and f (string? f) (file-exists? f)
(let-values ([(base file dir?) (split-path f)]) file))])
(datum->syntax-object (quote-syntax here) f stx))]))
;; This is a macro-generating macro that wants to expand
;; expressions used in the generated macro. So it's weird,
;; and we put much of the work in a helper macro,