A Pythonista's Impressions of Erlang
Thomas Lindgren
thomasl_erlang@REDACTED
Wed Jan 12 15:29:53 CET 2005
> To do it this way involves a quick hack to the
> compiler
> of a rather simple parse_transform to change the
> semantics of
> the compiler.
>
> Actually I see no reason why patterns like Var ++
> StringLiteral should not
> be compiled, especially since StringLiteral ++ Var
> *is* allowed - and therefore
> disallowing Var ++ StringLiteral violates the
> principle of least astonishment.
Some objections:
X ++ "string" would compile into string searching
(linear time), rather than pattern matching (constant
time).
There might be multiple matches, what to do about
those? (May I suggest backtracking? :-)
What about nested patterns, e.g.,
"foo:" ++ X ++ "=" ++ Y?
Will your simple parse transform really be all that
simple once we consider all the cases? (Perhaps the
best solution is to write it and see.)
However, I'll agree that more generally it might be
nice to have some sort of regexp patterns, especially
when doing the string processing tasks that tend to
pop up. (Parsing text based protocols, say?)
Also, regexps/string operations on binaries might be
more familar to people used to "strings as arrays".
Best,
Thomas
__________________________________
Do you Yahoo!?
The all-new My Yahoo! - Get yours free!
http://my.yahoo.com
More information about the erlang-questions
mailing list