[r6rs-discuss] Use backquote in "case"
> >> If "case" were defined in terms of backquote, though, this would be
> >> possible:
> >>
> >> (define some-const 'xxx)
> >>
> >> (case some-val
> >> [(,some-const)
> >> ...])
> > It's a too dangerous. We should avoid an implicit evaluation.
>
> What implicit evaluation? The unquote here, just like the one in
> quasiquote, is explicitly saying "evaluate this".
I agree, this is explicit and not implicit. From that perspective this
change is backwards-compatible; no existing code would be affected.
I agree too that the whole idea is a bit distasteful. :-) The problem is
that without the ability to use "constants" in case expressions I find
case rather useless. case absolutely forces you to embed magic values in
code; as programmers we're usually taught that that's a bad thing to do.
So this is an attempt to make the best of a bad situation.
> There might be other issues regarding when things are evaluated. For
> example, are the following two expressions equivalent:
> (case e0 [(constant ,e1) e2] [else e3])
> (case e0 [(,e1 constant) e2] [else e3])
According to the spec these would be turned into:
(cond [(memv e0 `(constant ,e1)) ...] ...)
(cond [(memv e0 `(,e1 constant)) ...] ...)
so I don't see how backquote would really make a difference. (In other
words, their form is different but their effect is the same--in the
absence of side-effects, at least. But that's another story.)
Received on Fri Nov 10 2006 - 12:59:29 UTC
This archive was generated by hypermail 2.3.0
: Wed Oct 23 2024 - 09:15:00 UTC