bug or feature?

Gunilla Arendt <>
Tue Apr 18 13:47:30 CEST 2006


 From the reference manual:

   6.4.2 String Prefix in Patterns

   When matching strings, the following is a valid pattern:

   f("prefix" ++ Str) -> ...


   This is syntactic sugar for the equivalent, but harder to read

   f([$p,$r,$e,$f,$i,$x | Str]) -> ...

Regards, Gunilla


Serge Aleynikov wrote:
> Could anyone explain why matches #5 and #6 below fail?  I didn't find in 
> documentation a limitation of not being able to specify a variable as 
> the first argument of the '++' transform.
> 
> Eshell V5.4.13  (abort with ^G)
> ()1> Prefix = "200".
> "200"
> ()2> Suffix = "100".
> "100"
> ()3> "200" ++ "100" = "200100".
> "200100"
> ()4> "200" ++ Suffix = "200100".
> "200100"
> ()5> Prefix ++ "100" = "200100".
> ** 1: illegal pattern **
> ()6> Prefix ++ Suffix = "200100".
> ** 1: illegal pattern **
> ()7> Prefix ++ Suffix.
> "200100"
> ()9> "200" ++ Suffix = v(7).
> "200100"
> 
> Regards,
> 
> Serge
> 
> 




More information about the erlang-questions mailing list