develooper Front page | perl.perl6.language | Postings from April 2005

Re: should we change [^a-z] to <-[a..z]> instead of <-[a-z]>?

Thread Previous | Thread Next
From:
Patrick R. Michaud
Date:
April 14, 2005 19:05
Subject:
Re: should we change [^a-z] to <-[a..z]> instead of <-[a-z]>?
Message ID:
20050415020600.GF5953@pmichaud.com
On Thu, Apr 14, 2005 at 05:21:05PM -0700, Larry Wall wrote:
> 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.  

So,     <[a.z]>  matches "a", ".", and "z", 
while   <[a..z]> matches characters "a" through "z" inclusive.

I think that works for me.  I'll implement it that way (and yes, there
*are* updates to PGE coming very soon!).  

I guess I can't complain too loudly about ".." over "-" for ranges
since I was the one who suggested replacing "," with ".." in quantifiers
(e.g., {1..3} instead of {1,3}).  Not that I'd be complaining anyway.  :-)

> 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.

Just to make sure I have it right, by "allow -" you mean that 
<[a-z]> matches "a", "-", and "z" and produces a warning 
about an unescaped '-'?

Pm

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About