[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

Re: [FWP] TPJ One-Liner #39



On Sat, Jul 10, 1999 at 09:27:19PM +0100, Adam Rice wrote:
> Quoting Ronald J Kimball (rjk@linguist.dartmouth.edu):
> > What is wrong with the POSIX character class syntax?  It provides a clear
> > name for each class, and does not conflict with regular character classes.
> 
> As with the rest of POSIX regular expression syntax, is is \(unforgivably\)
> ugly.

Ugly is a completely subjective term.  I just don't see it.


> > Backwards compatibility.  Regular expressions are a double-quotish
> > contexts, so \u already has meaning there, even within a character class.
> 
> This argument would carry some weight if there was any evidence that anyone
> had ever used \u inside a character class. But why would they? I've already
> made a start:
> 
> perl -ne 'print if /\[[^\]]*\\[ul]/' `find /usr/lib/perl5/ -name '*.p*'`
> 
> Since I don't have fast access to a CPAN mirror, I can't do an exhaustive
> search.

I just used \u inside a character class yesterday, to see if it would
work.  There ya go!  ;)

On the other hand, how ugly would it be for \w and [\w] to be equivalent,
but \u and [\u] to be different?


> > In addition, POSIX provides more than just [:upper:] and [:lower:]
> > character classes.  We can't implement all of them using \ escapes; we will
> > very quickly run out of characters to escape.
> 
> According to the egrep man page, there are 11. Many of which already have
> equivalents in Perl notation. It makes more sense to me to extend Perl's
> existing syntax to cover the rest rather than conceding an inch of ground to
> POSIX's horrible syntax.

There are 11 *right now*.  What do we do if we cram those 11 into the
backslashed alphabet, and then a future version of POSIX adds more
character classes?

Also, there has been talk on P5p of allowing user-definable POSIX-style
character classes.  That would not be possible with backslash escapes; no
extra characters to define meanings for.


Ronald

==== Want to unsubscribe from Fun With Perl?  Well, if you insist...
==== Send email to <fwp-request@technofile.org> with message _body_
====   unsubscribe