diff --git a/collects/mzlib/etc.ss b/collects/mzlib/etc.ss index 80ae0cd..0176857 100644 --- a/collects/mzlib/etc.ss +++ b/collects/mzlib/etc.ss @@ -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,