Olin.Shivers@CENTRO.SOAR.CS.CMU.EDU (07/24/88)
(let ([null? null?])
(define-macro! nil? (x)
`(,null? ,x)) ; note comma before null?
I don't use the Scheme's you use, but I think I can see at least one
problem with this macro: functions are *not* defined in Scheme to be
self-evaluating like, for example, integers are.
So instead of:
,null?
you need:
',null?
As in:
(let ((null? null?))
(define-macro! nil? (x)
`(',null ,x)))
-Olindorai@titan.rice.edu (Dorai Sitaram) (07/25/88)
`define-macro!', the form used to define macros in older versions of
Chez Scheme [TM, Cadence Research Systems] is also provided in the current
version (along with the fancier `extend-syntax'/`with'). However, the older
version (v.1.1, 1985) seems more powerful (expressive) than the current one
(v.2.0.3, 1987)!
In the old case, it is possible to specify not just text but closures in
a "macro"'s expansion pattern. For example, the following almost pointless
program,
(let ([null? null?])
(define-macro! nil? (x)
`(,null? ,x)) ; note comma before null?
works fine in v.1.1, `nil?' being a macro version of `null?'. As motivation
for using the closure `null?' rather than the variable `null?' in the above
macro expansion, one might consider that the global variable `null?' can now
be redefined to something else, but `nil?' will always test for nil-ness.
This ruse doesn't work in v.2.0.3:
The program (nil? 7) yields the diagnostic:
Error: nonsensical application (#<procedure null?> 7).
Anyone know why Cadence (Dybvig?) thought fit to do away with the old
Chez's more powerful macros? {I don't know Cadence's e-mail address.}
--dorai
ps: It might be argued that there might be newer ways (possibly using `extend-
syntax'/`with') to get the effect described above, if not with the same
program fragment. Nope. There just doesn't seem a way to get closures in
the expansion pattern in new Chez.gateley@mips.csc.ti.com (John Gateley) (07/26/88)
In article <1709@kalliope.rice.edu> dorai@titan.rice.edu (Dorai Sitaram) writes: >`define-macro!', the form used to define macros in older versions of >Chez Scheme [TM, Cadence Research Systems] is also provided in the current >version (along with the fancier `extend-syntax'/`with'). However, the older >version (v.1.1, 1985) seems more powerful (expressive) than the current one >(v.2.0.3, 1987)! Just a side note: you seem to be saying that the define-macro! form is more powerful than extend-syntax and with. This is not true. Extend-syntax can be used to do 3-d programming (the technique you describe in your message), and any macro. It is completely general. John Gateley p.s. Extend-syntax was created by Eugene Kohlbecker.