[plt-scheme] What the heck to put for deserialize-id and dir-path

From: Matthew Flatt (mflatt at cs.utah.edu)
Date: Sun Feb 27 08:53:27 EST 2005

At Thu, 24 Feb 2005 18:17:08 -0500, Greg Pettyjohn wrote:
> In particular, if the call site of the macro is NOT in a module, it 
> (used to) works fine.
> If the call site IS in a module then I need to add a provide to the 
> module and then I
> have a NASTY dependency on the dir-path field, which I can never get 
> right.
> How do I write my macro so that it is robust?

Use `(syntax-local-context)' to determine the expansion context. Don't
create a `provide' form if `(eq? 'top-level (syntax-local-context))'.
You might also want a check like this one near the start of parsing the
macro use:

        (unless (memq (syntax-local-context) '(top-level module))
	   "allowed only at the top level or within a module top level"

For the directory path, use

  (or (current-load-relative-directory)

I'll add this suggestion to the docs.


Posted on the users mailing list.