This is the mail archive of the
kawa@sourceware.org
mailing list for the Kawa project.
Re: Strange error output for undefined macros inside macros
On Fri, 2 Feb 2007, Per Bothner wrote:
> Kjetil S. Matheussen wrote:
> >
> >
> > On Thu, 1 Feb 2007, Per Bothner wrote:
> >>> (define (low-level-macro-helper all)
> >>> (eval `(dosomethingcoolwith ,@all)))
> >>>
> >>> (define-syntax low-level-macro
> >>> (syntax-rules ()
> >>> ((_ arg1 arg2 ...) (def-class-helper (quote (arg1 arg2 ...))))))
> >>
> >> I don't know if it is safe, but I'm 99% certain it's the wrong approach.
> >> You want to work *with* the compiler, not *against* it.
> >
> > But will I stumble upon the colon problem using this approach?
>
> The "colon problem" is just an example. You'll only run into it if you
> use identifiers containing colons, and in that case you can escape the
> colon.
>
> If you really don't want to do the right thing (i.e. define-syntax),
> t least dont't use eval to fake low-level macros. That's even worse
> than using defmacro or define-macro: it combines the problems
> of defmacro with breaking efficiency, static error detection, and
> lexical scoping.
>
> But I really suggest trying to use the define-syntax-case macro
> from http://sourceware.org/ml/kawa/2006-q4/msg00020.html .
> That gives you a fairly direct way of mapping defmacro macros
> to syntax-case macros:
>
Syntax-case macros sounds good, but I can't help having a feeling that
they might restrict my freedom. For example, can syntax-case macros
change variable names?
Can I do this with syntax-case macros?
#|kawa:1|# (define-macro (call-reversename func . args)
`(,(string->symbol
(list->string
(reverse
(string->list
(symbol->string
func)))))
,@args))#|(---:2|# #|(---:3|# #|(---:4|# #|(---:5|# #|(---:6|#
#|(---:7|# #|(---:8|#
#|kawa:9|# (call-reversename yalpsid 50)
50
#|kawa:10|#