From d3eb73d9897b23b47ab5122627e58c52bbfbf3c8 Mon Sep 17 00:00:00 2001 From: Eli Barzilay Date: Fri, 18 Mar 2005 20:35:57 +0000 Subject: [PATCH] added this-expression-file-name original commit: 106388724f571e96062423fed9ec65e9aeda3ccd --- collects/mzlib/etc.ss | 9 +++++++++ 1 file changed, 9 insertions(+) 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,