Adoption of perl/javascript-style regexp syntax

Richard O'Keefe ok@REDACTED
Thu Jun 4 02:16:42 CEST 2009


On 3 Jun 2009, at 6:50 pm, mats cronqvist wrote:
>
>  this discussion is about how to represent strings with many escapes,
>  not about regexps per se.

You did read the subject?

Actually, it's about people mistakenly THINKING they need strings with
many escapes, when what they really need is to get away from strings.
Regular expressions are one good example, but I've already provided
another: Windows UNC file names.  URLS, being similar to UNC names,
are an obvious third.

Imagine that you have
   - string
   - inside a JavaScript expression
   - inside an XML attribute
   - where the XML has to appear as data in an Erlang program.
Not an unusual occurrence these days.

r"xxx" or `xxx` just saves you ONE level of escaping, the very
last.  It does *NOTHING* to help with the others.  No amount of
hacking on the Erlang tokeniser will do anything about JavaScript
syntax or XML syntax.  And these fancy Perl-envious alternative
ways of quoting strings only help with _literal_ data, they don't
help with dynamically generated data.

Before arguing about the details of the solution,
shouldn't we make sure we are solving the right problem?

The right problem is how to handle MULTIPLE levels of nested languages
as SOME kind of data in such a way as to make it easier to get right.

The regular expression model shows us an excellent answer to the
_general_ problem.



More information about the erlang-questions mailing list