Re: not wanting something

2009-01-11 Thread Larry Wall
On Tue, Jan 06, 2009 at 04:41:30PM +0300, Richard Hainsworth wrote:
> Supposed I define
>
> regex digit { [0..9] }
>
> what is the negative?

You need to be careful about what you mean here by "negative".  If you mean 
"match
a single character that is not in the list", then it is as Patrick said.

> By analogy, it should be  but I cant find this in the Synopses  
> (possibly missed the relevant section).

Any assertion may be negated, including , but it doesn't mean
the same kind of negative.   and  are positive and
negative lookaheads, so the never match a character.  So

<-digit>

really means

 .

It just happens that . is looking at the same thing as , but
there's no requirement that they line up like that.

> Also, suppose I want a 'when' clause to fire when the test is *not* met.  
> What syntax should be used?
>
> So how would I do
> given {
>when ! // {say 'this is not a digit'} # this does not work
> }

That should work, and so should

when not //

since Boolean expressions are just tested outright and not compared
back to $_.

But in general, since switch statement cases are ordered, you should
usually match the case positively earlier and give it a different,
possibly null, behavior:

when /^$/{ }
when *  { say 'this is not a digit' }

So there is little need for syntactic relief here, I think.

Larry


Re: not wanting something

2009-01-06 Thread Patrick R. Michaud
On Tue, Jan 06, 2009 at 12:42:16PM -0500, Chas. Owens wrote:
> On Tue, Jan 6, 2009 at 10:12, Patrick R. Michaud  wrote:
> snip
> > Also, Perl 6 already provides a 'digit' rule by default, although
> > it's digits in the Unicode sense as opposed to simply the 0..9
> > sequence.
> snip
> 
> Please tell me that Perl 6 isn't going to make that same error the
> Perl 5.8 did.  

As far as I know,  means "Unicode alphabetic", and by analogy
one presumes that  is "Unicode digit".

> Or at least tell me that it will provide two classes:
> Unicode digit and digit you can do math with.  

It's entirely possible that in Perl 6 one can "do math" with
strings containing Unicode digits, making the distinction 
somewhat irrelevant, perhaps.  (I don't have proof of this, but 
I suspect it to be the case.)

I know that magical string autoincrement honors Unicode digit
sequences, at any rate.

Pm


Re: not wanting something

2009-01-06 Thread Chas. Owens
On Tue, Jan 6, 2009 at 10:12, Patrick R. Michaud  wrote:
snip
> Also, Perl 6 already provides a 'digit' rule by default, although
> it's digits in the Unicode sense as opposed to simply the 0..9
> sequence.
snip

Please tell me that Perl 6 isn't going to make that same error the
Perl 5.8 did.  Or at least tell me that it will provide two classes:
Unicode digit and digit you can do math with.  Unicode digit is nearly
worthless, and people keep confusing it for digit you can do math
with.  Shouldn't the Huffman encoding principle come into play and \d
be reserved for [0-9] and \p{IsDigit} (or the equivalent Perl 6
construct) be used for matching Unicode digits?


-- 
Chas. Owens
wonkden.net
The most important skill a programmer can have is the ability to read.