On Fri, Sep 11, 2009 at 12:05 AM, Eli Barzilay <[email protected]> wrote:
>
> * The kind of hygiene-braking that makes a `make-foo' out of a *given*
>  `foo' has no problems.

Actually, it has a few subtle problems.  First, is what if you don't want
`make-foo', but something more like `internal-make-foo' and you want to
manually define `make-foo' to do something special.  Second (and I think
more important), you can't easily tell that in code like this:
  (let (...)
     (define-local-struct foo bar baz)
     ...
     (make-foo ...)
     )

make-foo is *not* a free variable.

Admittedly, it is convenient to have symbol-pasting macros, but it isn't *that*
much more convenient (you didn't have to type `make-foo' at the
definition point,
but you still have to type it everywhere else, so the savings is minor).
The alternative of requiring the user to explicitly name the symbols
he is binding
also allows him to break the naming pattern when necessary (ala
make-internal-foo)
and makes it easier to walk the code, which benefits seem to me to outweigh
the typing.

>
> * Besides the first item, `syntax-rules' suffers from a number of
>  additional problems.  One is the heavy cost of doing any kind of
>  looping or other kinds of computations: in addition to making it
>  hard to follow (and if you read Joe's "Merely Eccentric" text you
>  probably know about that), it is slow.  Usually that's not a
>  problem, but when you deal with macros that expand to macros
>  expansion times can become painful.

Yes.  This is horrible.  I expect the slowness wouldn't continue to
be an issue if people wrote more macros, but the difficulty of writing
complex macros is terrible.

However, as Oleg Kiselyov has pointed out, there is no requirement
that you program directly in syntax rules.  His scheme->syntax-rules
compiler allows you to write macros in a restricted subset of scheme
and have them work like the old-fashioned `defmacro' macros except
with hygiene.

I think this is a promising way to define a higher-level macro language
that is easier to use, and I don't know why it hasn't been further investigated.

> * Another problem: write a `bind' macro that does this:
>
>    > (bind ((x 1) (x 1)) x)
>    bind: duplicate identifier in: (bind ((x 1) (x 1)) x)

Horrid to write, but possible.


Oh, I almost forgot.  You could (in principle) write a syntax-rules preprocessor
in a language other than Scheme.  The `phase' problems of syntax-case aren't
an issue.

-- 
~jrm

_______________________________________________
r6rs-discuss mailing list
[email protected]
http://lists.r6rs.org/cgi-bin/mailman/listinfo/r6rs-discuss

Reply via email to