Re: HOF implementation of "until"



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
.



Relevant Pages

  • Re: [SLE] Postfix - Sandy - 1 more Q re: /etc/postfix/recepient_check
    ... I'm a little hesitant to answer, because I'm not sure what "regular" means in this case. ... Regular expressions are an absolute must for adminstrators. ... You will encounter these pattern matching expressions in most scripting and programming languages. ... Additionally it will use the content in the round brackets as $1, $2 (content of first found expression in brackets, second found... ...
    (SuSE)
  • Re: Regular Expression question
    ... I want to use the Regular Expressions MatchCollection to match multiple ... I want to match the pattern that looks like "Word, ... Quantifiers in regex are gready by default - in other words, ... to tell the regex engine to not be gready, ...
    (microsoft.public.dotnet.languages.vb)
  • Re: [SLE] Postfix - Sandy - 1 more Q re: /etc/postfix/recepient_check
    ... I'm a little hesitant to answer, because I'm not sure what "regular" means in this case. ... Regular expressions are an absolute must for adminstrators. ... You will encounter these pattern matching expressions in most scripting and programming languages. ... Additionally it will use the content in the round brackets as $1, $2 (content of first found expression in brackets, second found... ...
    (SuSE)
  • Re: Regular Expression question
    ... I want to use the Regular Expressions MatchCollection to match multiple ... I want to match the pattern that looks like "Word, ... Dim matches As MatchCollection = reg_exp.Matches ...
    (microsoft.public.dotnet.languages.vb)
  • Re: HOF implementation of "until"
    ... > Case expressions themselves may be regarded as syntactic sugar ... > as described in figures 3.1 and 3.2 from the Haskell report. ... I didn't mean that case expressions can be translated to patterns (or ... do-Notation, list comprehensions, and pattern matching vs. case-statements. ...
    (comp.lang.functional)

Loading