Subject: Re: quote , . , macros [Was : Re: why is (car ''abcde) evaluates to quote ?]
From: rpw3@rigden.engr.sgi.com (Rob Warnock)
Date: 24 Mar 2001 03:16:58 GMT
Newsgroups: comp.lang.scheme
Message-ID: <99h3ja$3as16$1@fido.engr.sgi.com>
David Rush  <kumo@bellsouth.net> wrote:
+---------------
| I think that the requirement that macro-bodies use the definition-context
| bindings helps out here in that it requires that all of the macro
| definitions be processed before any of them are expanded.
| 
|  Larceny v1.0a1 (precise:SunOS5:split) (lth 21-Dec-98 16:23:57)
|  > (define-syntax foo (syntax-rules () ((foo x) (car x))))
|  > (define-syntax car (syntax-rules () ((car x) (cdr x))))
|  > (define x (cons 'a 'b)) 
|  > (foo x)
|  b
|  > (car x)
|  b
+---------------

Interesting. MzScheme v.101 barfs on this:

	> (require-library "synrule.ss")
	> (define-syntax foo (syntax-rules () ((foo x) (car x))))
	> (define-syntax car (syntax-rules () ((car x) (cdr x))))
	> (define x (cons 'a 'b)) 
	> (foo x)
	procedure application: expected procedure, given: #<macro>; \
	  arguments were: ((g9 x) (g9 . car))
	> (car x)
	procedure application: expected procedure, given: #<macro>; \
	  arguments were: ((g10 x) (g10 . cdr))
	> 

However, the documentation *does* warn:

	This implementation of syntax rules can only be used with the
	following syntactic forms: quote if begin set! define lambda letrec
	let let* do case cond. If any other form is used in the macro
	definition or macro application, the results are unpredictable.


-Rob

-----
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