On Sep 12, Joe Marshall wrote:
> 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.

You use a local scope, as usual.

> 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.

That's a point agains being able to do this in general.  A similar
point can be (and have been) done against macros in general.  Or
continuations.


> However, as Oleg Kiselyov [...] scheme->syntax-rules [...]  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.

I very much disagree with this.  The whole idea of starting with a
"simple template language" that is TM-complete, then converting "real
code" to this language instead of just using the language sounds like
a redundant exercise.  Very similar to starting with a lazy
side-effect-free functionaly language, then butchering it to the point
where code looks just like your average C code.


> 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.

... the preprocessed language *is* your phase 1 -- the fact that it's
not Scheme should make it clear.  (And if you extend the preprocessed
language with modules and macros, you get more phases.)


On Sep 12, Joe Marshall wrote:
> Ugly, but effective:
> 
> (define-syntax syntax-error
>    (syntax-rules ()
>      ((syntax-error) (syntax-error "Bad use of syntax error!"))))
> 
> Now write calls to (syntax-error "Duplicate binding.") and you'll
> get expansion time errors that look something like this
> 
> error: no matching clause in (syntax-error "Duplicate binding.")
> 
> Depending on how the implementation reports these things, of course.
> 
> Yes, it is ugly and crude, but it works.

I'll repeat and re-edit my original challenge (I missed the important
bit), and will add a few more:

    > (bind ((x 1) (x 1)) x)
    bind: duplicate identifier x in: (bind ((x 1) (x 1)) x)
    > (bind ((9 x)) x)
    bind: non-identifier 9 in: (bind ((9 x)) x)

And if anyone is tempted to actually try to do it with `syntax-rules',
keep in mind that a `syntax-case' solution is probably less than 10
lines long, and easily readable.

-- 
          ((lambda (x) (x x)) (lambda (x) (x x)))          Eli Barzilay:
                    http://barzilay.org/                   Maze is Life!

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

Reply via email to