[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: MzScheme and SML




> From: Shriram Krishnamurthi <sk@cs.brown.edu>
> 
> We've made extensive comparisons of MzScheme to SML/NJ.  They are more
> voluminous than we can possibly list here.  Some key differences:
> 
[snip]
> 
> - Scheme has a very advanced macro system; ML has none at all
> 

This interests me.  Here is a quote from Andrew Appel of Princeton, one of
SML's designers, commenting on SML's lack of macros:

    This is clearly an advantage, not a disadvantage.  For the programmer
    to have to calculate a string-to-string rewrite of the program before
    any semantic analysis invites problems of the worst kind.  Where macros
    are used to attain the effect of in-line expansion of functions, they
    are doing something that should be done by an optimizing compiler.
    Where macros are used to attain call-by-name, the effect can be
    acheived by passing a suspension as an argument; in ML this is written
    with the syntax fn()=> which though admittedly ugly is fairly concise,
    and is better than tolerating the semantic havoc wrought by macros.

    [From "A critique of Standard ML", 1992]

I respect Appel's opinions, and SML is nice in many ways, but I don't know
what to make of this statement.  It sounds like he's confusing scheme
macros (structure-to-structure rewrite) with C macros (string-to-string
rewrite).  I agree that the latter are horrible from many perspectives, but
I would expect Appel to know the difference.  I also agree that the former
can be simulated the way he describes, but it's hardly seamless or
convenient to the programmer (not to mention inefficient).  Try adding a
new control construct to SML and see how elegant it is :-)  I think it would
be more elegant in Haskell, but I haven't tried it.

A more interesting question is what he means by "semantic havoc".  Does
anyone know of any work on incorporating macros into statically typed
languages?  It doesn't sound like an intractable problem to me.  Of course,
scheme's syntax makes it much easier :-)  In fact, although I like SML and
ocaml I find their syntaxes extremely confusing in places.  I wish there
were versions of those languages with scheme-like syntaxes.

For me, scheme is appealing precisely because of the extra semantic power
provided by functional programming and macros.  Each of these allow the
programmer to raise the level of abstraction of their code significantly;
together, it's much more powerful.

Mike

--------------------------------------------------------------
Mike Vanier	mvanier@bbb.caltech.edu
Department of Computation and Neural Systems, Caltech 216-76
GNU/Linux: We can't lose; we're on a mission from God.