[erlang-questions] Strings as Lists
Lev Walkin
vlm@REDACTED
Mon Feb 18 22:13:55 CET 2008
Brian Cully wrote:
> On 18-Feb-2008, at 09:49, Joe Armstrong wrote:
>
>> ~n"...." turn off quoting
>> ~r"...." string is a regexp
>> ~x"..." string is xml
>> ~x/FlunkyStuff ... FunkyStuff (string is xml terminated by
>> FunkyStuff)
>> ~myExpander/FunkyStuff .... FunckyStuff
>
> I agree with the difficulty of embedding languages into strings, and
> avoid it myself whenever possible. Mostly because I'm puritanical, but
> whatever.
>
> My issue regards overloading the double-quote character. I'd rather
> something completely generic to avoid situations like this:
>
> ~r"/"/"
> ~xml"<root attr="oops"/>"
> and so on.
>
> perl's qr/w/x operators might be worth looking at. They don't
> completely fix the issue, but they work around it by allowing the
> programmer to specify delimiters.
>
> Personally, I'd rather just natural syntax. Both regexp and xml
> naturally terminate or have errors, so switching the parser into an
> xml/regexp mode seems reasonable to me.
It then becomes a problem to parse the straight HTML, which could
contain JavaScript. The browser is supposed to have similar smarts
in how it treats javascript quoting inside a quoted attribute.
However, this would ask for the order-2 smarts from the erlang parser.
I'd propose something like trac code, which is
{{{literal"string"<xml>, code, etc.}}}
where the number and the shape of braces is debatable. To avoid
confusion with tuples, perhaps 3 angle braces would do. Example:
<<<<html><head>"some invalid> htmlcode</html>>>>
which parses quite straightforwardly.
--
vlm
More information about the erlang-questions
mailing list