Choking on Syntactic Sugar
Hakan Stenholm
etxhste@REDACTED
Tue Mar 13 19:17:28 CET 2001
>Maurice,
>
>On Tue, Mar 13, 2001 at 06:09:57PM +1100, Maurice Castro wrote:
>> My question is in 3 parts:
>>
>> 1) is this behaviour desirable
>
>Yes,
>
>> - note it is pure syntactic sugar for [$[, $^ | S0]
I'm a littel confused here so I would be happy if anyone would care to explain.
After reading the documentation I get the impression that ++ is simply a short
form of lists:append/2.
I guess that this is not the case consdering that only arithmetic expressions
that evaluate to constants are allowed in a patterns.
So what exactly is a ++:
"[^" ++ S0 is the same as [$[, $^ | S0]
but what would happen in
fun(List1 ++ List2) -> ...
is it legal ? we only know what List1 is at run time so there shouldn't be any
way to expand it to some constant pattern as in reg4("[^" ++ S0) ?
>Yes,
>
>> 2) is this behaviour intended
>
>Yes,
>
>> 3) is it documented
>
>Yes, in the 4.4 Extensions pdf document at www.erlang.org.
>
>>
>> Comments welcome.
>>
>
>
>Yeah, if you feel the ++ operator is weird, take a look at the
>-- operator which is also described in the same doc, it's really
>weird. Not useless though.
>
>--
>Claes Wikstrom -- Caps lock is nowhere and
>Alteon WebSystems -- everything is under control
>http://www.bluetail.com/~klacke
More information about the erlang-questions
mailing list