Re: HOF implementation of "until"
- From: Andre <andre@xxxxxxxxxxxxx>
- Date: Thu, 10 Nov 2005 10:39:32 -0500
Dirk Thierbach wrote:
> And now pattern matching is also syntactic sugar? :-)
>From the Haskell report:
"Patterns appear in lambda abstractions, function definitions, pattern bindings, list
comprehensions, do expressions, and case
expressions. However, the first five of these ultimately translate into case expressions, so
defining the semantics of pattern
matching for case expressions is sufficient."
Case expressions themselves may be regarded as syntactic sugar
as described in figures 3.1 and 3.2 from the Haskell report.
I give one example of the productions there. The fact that
Haskell compilers may optimize these is beside the point.
case v of { K p1 ...pn -> e; _ -> e' }
= case v of {
K x1 ...xn -> case x1 of {
p1 -> ... case xn of { pn -> e ; _ -> e' } ...
_ -> e' }
_ -> e' }
(at least one of p1, ..., pn is not a variable; x1, ..., xn are new
variables)
In Lisp/Scheme, these productions would be the macro, so this kind
of semantics can be portably expressed in the language itself.
Once again, the fact that some Scheme compilers would optimize this by
various static methods is really beside the point.
Cheers
Andre
.
- Follow-Ups:
- Re: HOF implementation of "until"
- From: Dirk Thierbach
- Re: HOF implementation of "until"
- From: Joachim Durchholz
- Re: HOF implementation of "until"
- References:
- Re: HOF implementation of "until"
- From: Dirk Thierbach
- Re: HOF implementation of "until"
- From: Adrian Kubala
- Re: HOF implementation of "until"
- From: Vesa Karvonen
- Re: HOF implementation of "until"
- From: Dirk Thierbach
- Re: HOF implementation of "until"
- From: Andre
- Re: HOF implementation of "until"
- From: Dirk Thierbach
- Re: HOF implementation of "until"
- Prev by Date: Re: Hugs question
- Next by Date: Re: HOF implementation of "until"
- Previous by thread: Re: HOF implementation of "until"
- Next by thread: Re: HOF implementation of "until"
- Index(es):
Relevant Pages
|
Loading