[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Chicken-users] unbound variable: or
From: |
John Cowan |
Subject: |
Re: [Chicken-users] unbound variable: or |
Date: |
Sun, 31 May 2015 10:00:01 -0400 |
User-agent: |
Mutt/1.5.20 (2009-06-14) |
chi scripsit:
> But I can't find anywhere that really explains why
> that's _fundamentally_ broken, not just ugly.
Define-macro has two problems: it prevents (as opposed to selectively
escaping from) hygiene, and it only supports global macros.
Unhygienic syntax has exactly the same problem as dynamically scoped
variables in Elisp or other pre-Common Lisps: you can't tell what
code does without examining its use of identifiers.
> Incidentally, I'm pretty sure define-syntax isn't hygenic. syntax-rules is
> hygenic. You can still ruin yourself with define-syntax, like:
That's true. Low-level macro systems allow both hygiene and non-hygiene,
and both can be defined using define-syntax, let-syntax, let*-syntax,
or letrec-syntax.
> (define-syntax a
> (lambda (form rename compare)
> '(define b 23)))
For portability, you should always wrap the lambda in (er-macro-transformer
...),
even though that does nothing on Chicken. That way, if your code is ever
ported to a Scheme that provides syntax-case, you'll get an immediate
error rather than randomly going wrong.
> I would like to state for the record that even defining hygenic syntax is
> a pretty ruinous idea. You have to be very careful of what you're doing, and
> confident that it's a good idea, because it is literally impossible for
> someone
> to tell what your program means without first calculating all of the syntax
> rules you have defined in their head.
That's where syntax-rules shines: it gives up the full power of Scheme
in favor of safety and clarity. IMO, there is really no need to use
low-level macros ever.
> It is kind of fun that you can write an uncomputable program though.
It makes things like continuous build servers hard, though.
--
John Cowan http://www.ccil.org/~cowan address@hidden
Mos Eisley spaceport. You will never see a more wretched hive of scum
and villainy --unless you watch the Jerry Springer Show.
--georgettesworld.com
- Re: [Chicken-users] unbound variable: or, (continued)
- Re: [Chicken-users] unbound variable: or, Jinsong Liang, 2015/05/29
- Re: [Chicken-users] unbound variable: or, Matt Gushee, 2015/05/29
- Re: [Chicken-users] unbound variable: or, John Cowan, 2015/05/29
- Re: [Chicken-users] unbound variable: or, Peter Bex, 2015/05/30
- Re: [Chicken-users] unbound variable: or, Michele La Monaca, 2015/05/30
- Re: [Chicken-users] unbound variable: or, Peter Bex, 2015/05/30
- Re: [Chicken-users] unbound variable: or, Michele La Monaca, 2015/05/30
- Re: [Chicken-users] unbound variable: or, chi, 2015/05/31
- Re: [Chicken-users] unbound variable: or, Peter Danenberg, 2015/05/31
- Re: [Chicken-users] unbound variable: or, Peter Bex, 2015/05/31
- Re: [Chicken-users] unbound variable: or,
John Cowan <=
- Re: [Chicken-users] unbound variable: or, John Cowan, 2015/05/30
Re: [Chicken-users] unbound variable: or, Daniel Leslie, 2015/05/27