[plt-scheme] On macros and Scheme
I think we're still a long way from making macros obsolete
(parameterize is a macro, for example). The class system and the unit
system are implemented with macros, as is the contract system. It
seems hard to make them go away without building them into the
compiler.
Robby
On Dec 19, 2007 4:14 AM, Majorinc, Kazimir <kazimir at chem.pmf.hr> wrote:
> Joshua Zucker wrote:
> > I enjoy the blog "Good Math, Bad Math", and the latest installment is
> > particularly relevant to us:
> > http://scienceblogs.com/goodmath/2007/12/macros_why_theyre_evil.php
> >
> > Basically he says that macros are evil, and some are eviller than
> > others, but, well, maybe Scheme gets it right, and if only there were
> > a macro debugger ...
> >
> > I think these PLT guys have something figured out, maybe :)
> >
> Macro Stepper is really good one, but author is right, macros are bad,
> they are hard to debug, macro expansion is very space and time consuming
> - unsuitable for runtime generated code, not first-class citizens ...
> Macro semantics and syntax of macro call is still more handy/powerful
> than functions, but with few I'd say, feasible improvements in Scheme
> semantics, functions could do everything macros can. Look at this two
> functions:
>
> (define (display-expression-and-value expr env)
> (parameterize ((current-namespace env))
> (display "(evaluates-to ")
> (display expr)
> (display " ")
> (display (eval expr))
> (display ") \n")))
>
> (define (++ var env)
> (parameterize ((current-namespace env))
> (eval `(set! ,var (+ (eval ,var) 1)))))
>
> (define x 4)
> (display-expression-and-value '(+ x x) (current-namespace))
> (++ 'x (current-namespace))
> (display x)
>
> ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
> ;(evaluates-to (+ x x) 8)
> ;5
>
> This is typically done by macros, namespaces make it possible by
> function. Unfortunately, syntax of the function call in this example is
> quite a bit uglier and eval does not recognize all variables - but
> really only few small steps are left from this point to making macros
> obsolete.
>
>
>
> _________________________________________________
> For list-related administrative tasks:
> http://list.cs.brown.edu/mailman/listinfo/plt-scheme
>