Subject: Re: Dr Scheme define-macro problem
From: rpw3@rigden.engr.sgi.com (Rob Warnock)
Date: 27 May 2001 00:44:41 GMT
Newsgroups: comp.lang.scheme
Message-ID: <9epilp$bhb9o$1@fido.engr.sgi.com>
Ronald Legere <legere@adelphia.net> wrote:
+---------------
| I was trying some very simple examples
| with define-macro and get the following error
| build-path: expects type <string or 'up or 'same> as 1st argument, given:
| #f; other arguments were: "C:\\"
...
| all I did was: (define-macro test 3)
| ... just define-macro is broken.
+---------------

Well, if define-macro is "broken", the *only* thing that's broken
is the error message -- you're not using it correctly.  From the
on-line manual (which you should be able to get to through the
Help Desk, I think):

    <URL:http://www.cs.rice.edu/CS/PLT/packages/doc/mzscheme/node144.htm>
    Global macros are defined with define-macro: 
      (define-macro name procedure-expr)
    When the macro is later ``applied,'' the (unevaluated) argument
    S-expressions are passed to the procedure obtained from procedure-expr.
    The result is a new S-expression that replaces the macro application
    expression in its context. If procedure-expr evaluates to a
    non-procedure, the exn:misc exception is raised.

And, indeed, when I try your example, I (correctly) get an error:

    > (define-macro test 3)
    define-macro: not a procedure
    > 

Compare this with using a procedure:

    > (define-macro test (lambda () 3))
    > (+ 21 (test))
    24
    > 

Capische?


-Rob

p.s. Or pehaps were you trying to define an identifier macro instead?
See <URL:http://www.cs.rice.edu/CS/PLT/packages/doc/mzscheme/node145.htm>
for the details, but:

    > (define-id-macro test 3)
    > (+ 15 test)
    18
    > 

-----
Rob Warnock, 31-2-510		rpw3@sgi.com
SGI Network Engineering		<URL:http://reality.sgi.com/rpw3/>
1600 Amphitheatre Pkwy.		Phone: 650-933-1673
Mountain View, CA  94043	PP-ASEL-IA