On 14 Apr, Larry Wall wrote:

: In writing some character class translation, I realized that
: 
:     <-[a-z]>
: 
: and its ilk are rather hard to read because of the two hyphens
: that mean different things.  We can't use <![a-z]> because that's a
: 0-width lookahead.  Given that we're trying to get rid of special
: exceptions, and - in character classes is weird, and we already
: use .. for ranges everywhere else, and nobody is going to put a
: repeated character into a character class, I'm wondering if
: 
:     <-[a..z]>
: 
: should be allowed/encouraged/required.  It greatly improves the
: readability in my estimation.  The only problem with requiring .. is
: that people *will* write <[a-z]> out of habit, and we would probably
: have to outlaw the - form for many years before everyone would get
: used to the .. form.  So maybe we allow - but warn if not backslashed.
: 
: Larry

I think, if we bear in mind, as it has been stressed previously, that
many changes concerning regular expressions have been introduced and
require users to assimilate themselves accordingly, it doesn't seem
unreasonable requiring to write double-dot instead of a hyphen; it also
fits the "Principle of least surprise" idiom nicely, in my opinion.

Nevertheless, as mentioned by David, <[a...]> would become rather
confusing to people first and secondly to the compiler; although,
regardless whether we assume dot preceeds double-dot or vice-versa,
there would be an expansion enforced (what I'd expect), perhaps
accompanied by a warning.

I agree on a warning upon non-escaped hyphen.

Steven

Reply via email to