Re: RFC 138 (v1) Eliminate =~ operator.

2000-08-23 Thread Nathan Wiger
> : =~ has no real world equivalent, and in fact I don't know how to > : pronounce it in English so that $x =~ /a/ makes sense. > > Yes, that's all pretty much on the mark. Not true, IMO. In math, =~ is used to indicate "rough equivalence". (Actually, the ~ goes on top of the =, but this is a mi

Re: RFC 138 (v1) Eliminate =~ operator.

2000-08-24 Thread Nathan Wiger
Nathan Torkington wrote: > > Nathan Wiger writes: > >$x =~ /a/; # $x is roughly equivalent to a > > I've been going at high speed through this thread, but has > anyone mentioned: > > m{$foo}{^baz.*bar$}i > s{$foo}{(\w+) \1}{$1}g > > With th

Re: RFC 138 (v1) Eliminate =~ operator.

2000-08-24 Thread Nathan Wiger
> > eq and ne are far more confusing. > > Hm. I've never had problems with this, although it does confuse me to go > back to the shell's [ ] (aka test) and have them be backwards. Yeah, I've got them finally sorted out, it only took me about 5 years... ;-P > >if ( $x == m/stuff/ ) { ... } >

Re: RFC 138 (v1) Eliminate =~ operator.

2000-08-25 Thread Nathan Wiger
Nathan Torkington wrote: > > $foo->name . " says " . $bar->text . " hello to " . $baz->actor > > which isn't a win! You'll probably like RFC 103 then. It addresses this very thing. I just didn't stop to think that m// was just a fancy qq//. -Nate

New match and subst replacements for =~ and !~ (was Re: RFC 135 (v2) Require explicit m on matches, even with ?? and // as delimiters.)

2000-08-25 Thread Nathan Wiger
[cc'ed to -regex b/c this is related to RFC 138] Proposed replacements for m// and s///: >match /pattern/flags, $string >subst /pattern/newpattern/flags, $string > > The more I look at that, the more I like it. Very consistent with split > and join. You can now potentially match on @mul

Re: RFC 112 (v2) Assignment within a regex

2000-08-27 Thread Nathan Wiger
>if (/Time: (..):(..):(..)/) { > $hours = $1; > $minutes = $2; > $seconds = $3; > } > > This then becomes: > > /Time: (?$hours=..):(?$minutes=..):(?$seconds=..)/ > > This is more maintainable than counting the brackets and easier to understand > for a complex r

Re: RFC 164 (v1) Replace =~, !~, m//, and s/// with match() and subst()

2000-08-27 Thread Nathan Wiger
> =head1 TITLE > > Replace =~, !~, m//, and s/// with match() and subst() In a marked oversight, I'd also like to note that tr// would be replaced with trade: Perl 5 Perl 6 --- -- $str =~ tr/a/b/;$new =

Re: RFC 164 (v1) Replace =~, !~, m//, and s/// with match() and subst()

2000-08-27 Thread Nathan Wiger
Nathan Torkington wrote: > > When I was thinking about this very topic yesterday and today, I > came up with this problem: > > @strs = (); > match /pat/, @strs; # surprise! I'm matching on $_ > > That is, how do you tell an empty array from no arguments? Easy: We'll just use lazy evalua

Re: RFC 164 (v1) Replace =~, !~, m//, and s/// with match() and subst()

2000-08-27 Thread Nathan Wiger
Nathan Torkington wrote: > > Hmm. This is exactly the same situation as with chomp() and somehow > chomp() can tell the difference between: > > $_ = "hi\n"; > chomp; > > and > > @strings = (); > chomp @strings; Good point. I was looking at it from the general "What's wrong with how @

Re: RFC 164 (v1) Replace =~, !~, m//, and s/// with match() and subst()

2000-08-28 Thread Nathan Wiger
Jonathan Scott Duff wrote: > > I think that C is too syntactically close yet semantically far > from C that the evil demons of confusion will rear their ugly > heads. I agree too, any suggestions are welcome. The fact that 'sub' and 'substr' are already taken makes this tough... > Given the ab

Re: RFC 164 (v1) Replace =~, !~, m//, and s/// with match() and subst()

2000-08-28 Thread Nathan Wiger
Tom Christiansen wrote: > > There are thirteen years of precedent, not to mention the millions of users, > who are completely accustomed to writing expressions like > > next if /\s+/ || /\w+/; > > It's nearly part of Perl's language signature. I wouldn't count > on this going away if you s

Re: RFC 110 (v3) counting matches

2000-08-28 Thread Nathan Wiger
Mark-Jason Dominus wrote: > > > > $count = () = $string =~ /pattern/g; > > > > Which I find cute as a demonstration of the Perl's context concept, > > but ugly as hell from usability viewpoint. > > I'd really like to see an RFC that looks into making the following > features more orthogonal:

Re: RFC 164 (v1) Replace =~, !~, m//, and s/// with match() and subst()

2000-08-28 Thread Nathan Wiger
Tom Christiansen wrote: > > How nice of you to put words in my mouth. Please cite me the precise > message ID, date, and appropriate text in which I said "we can't > change anything because of precedent". First off, I wasn't trying to insult you, or push a hot button, or suggest we should destro

Creating Perl 6, not Perl++ (was Re: RFC 164 (v1) Replace =~, !~, m//, and s/// with match() and subst())

2000-08-28 Thread Nathan Wiger
Tom Christiansen wrote: > > But if *MOST* perl1 .. perl5 programs aren't going to work unchanged, > that means that most people's existing perl knowledge-base will no > longer be valid. That probably means that they aren't going to be > able to just type in the Perl that they already know, either

Re: RFC 110 (v2) counting matches

2000-08-29 Thread Nathan Wiger
Mark-Jason Dominus wrote: > > m/.../Count (instead of m/.../t) > m/.../iCount (instead of m/.../it) > m/.../Count,i (instead of m/.../ti) > m/.../Count,Insensitive (instead of m/.../ti) Blech, no. Please. Less typing good.

Re: RFC 110 (v3) counting matches

2000-08-29 Thread Nathan Wiger
Tom Christiansen wrote: > > $count = getpwnam("tchrist")/l; > $count = getpwnam("tchrist", LIST); > $count = getpwnam("tchrist")->as_list; > > All of those, frankly, suck. This is much better: > > $count = () = getpwnam("tchrist"); Hmmm. I agree a general purpose mechanism is g

Re: RFC 110 (v3) counting matches

2000-08-29 Thread Nathan Wiger
Tom Christiansen wrote: > > >While I agree that /l is bad, I think going through the crap of "= () =" > >is even worse. Does it work? Yes. But is it easily usable and fun, even > >for non-experts? No. > > Oh, for crying out loud--at some point, you have to stop tossing > rotting fish for the sta

Re: RFC 110 (v3) counting matches

2000-08-29 Thread Nathan Wiger
Tom Christiansen wrote: > > Goodness, it certainly does. It's loads easier than learning a new buzz^Wkeyword > or a new switch, because you already know it. Nobody with a sound mind would ever suggest that: > $stuff = () = $r =~ /crap/shit/; Wouldn't still work. At least not me. But these t

Re: RFC 110 (v3) counting matches

2000-08-29 Thread Nathan Wiger
Jonathan Scott Duff wrote: > > I'll agree that /l is bad too. But I think adding a new "list" > keyword is also bad. What about other contexts? Are we going to have > "scalar", "list", "hash", "boolean", "string", "number", etc.? Not to > mention (even though I am) user-defined contexts (my D

Re: RFC 110 (v3) counting matches

2000-08-29 Thread Nathan Wiger
Tom Christiansen wrote: > > >And hashes are assembled just like lists anyways: > > > %hash = list get_key_vals; > > %hash = (key, val, key2, val2); # same thing > > Eh? List context is conferred by the % on the LHS. You need > no redundant listification redundancy there. I was trying to

Re: RFC 165: Allow variables in a tr///

2000-08-29 Thread Nathan Wiger
> tr('a-z', 'A-Z', $str) > > replaces a-z with A-Z, and > > tr($foo, $bar, $str) > > replaces the characters from $foo with the characters from $bar. > No special syntax is necessary. This is actually right up the alley of v2 of RFC 164, which I am editing currently. Exactly, i

Re: Overlapping RFCs 135 138 164

2000-08-29 Thread Nathan Wiger
Mark-Jason Dominus wrote: > > RFC135: Require explicit m on matches, even with ?? and // as delimiters. This one is along a different line from these two: > RFC138: Eliminate =~ operator. > RFC164: Replace =~, !~, m//, and s/// with match() and subst() Which I could see unifying. I'd ask peo

Re: RFC 165 (v1) Allow Varibles in tr///

2000-08-29 Thread Nathan Wiger
Mark-Jason Dominus wrote: > > I think the reason this hasn't been done before it because it's *not* > quite straightforward. Before everyone gets tunnel vision, let me point out one thing: Accepting variables in tr// makes no sense. It defeats the purpose of tr/// - extremely fast, known translit

Re: RFC 165: Allow variables in a tr///

2000-08-29 Thread Nathan Wiger
Tom Christiansen wrote: > > There is *nothing*wrong* with any of them, and to suggest breaking > them is extremely demoralizing. Agreed. 100%. But wait for the RFC, I think you'll find you might actually like it. It doesn't break *any* of Perl 5's regex expressions. Not one. And it adds a whole

Re: RFC 165 (v1) Allow Varibles in tr///

2000-08-29 Thread Nathan Wiger
Tom Christiansen wrote: > > >tr///e is the same as s///g: > > > >tr/$foo/$bar/e == s/$foo/$bar/g > > I suggest you read up on tr///, sir. You are completely wrong. Yep, sorry. I tried to hit cancel and hit send instead. I'll shut up now. -Nate

Re: RFC 170 (v1) Generalize =~ to a special-purpose assignment operator

2000-08-29 Thread Nathan Wiger
> This RFC proposes a simple use for C<=~>: as a last-argument rvalue > duplicator. What this means is that an expression such as this: > >$value = dostuff($arg1, $arg2, $value); > > Could now be rewritten as: > >$value =~ dostuff($arg1, $arg2); David Nicol and I were brainstorming off

Re: Overlapping RFCs 135 138 164

2000-08-29 Thread Nathan Wiger
Steve Fink wrote: > > Hm. Larry didn't really like anything that would reverse the order of > the pattern and the expression to be matched against, and I think I > agree at least that it should always be possible to put the direct > object at the beginning, preferably in a way usable by more than

Re: copying and s/// (was Re: Overlapping RFCs 135 138 164)

2000-08-30 Thread Nathan Wiger
Uri Guttman wrote: > > TC> ($this = $that) =~ s/foo/bar/; > TC> for (@these = @those) { s/foo/bar/ } > > TC> You can't really do those in one step without it. RFC 164 v2 has a new syntax that lets you do the above or, if you want: $this = s/foo/bar/, $that; @these = s/foo/b

Re: copying and s/// (was Re: Overlapping RFCs 135 138 164)

2000-08-30 Thread Nathan Wiger
Mike Lambert wrote: > > or even: > @a = s/a+/a/, @a; This is actually the native syntax from RFC 164. > Basically, the argument is that you could theoretically do @a =~ s/a+/a/ > with QS, along with many other things. So perhaps, imo, it would be best > to just let QS handle it. I'm fine with t

Re: RFC 145 (alternate approach)

2000-09-05 Thread Nathan Wiger
I think it's cool too, I don't like the @^g and ^@G either. But I worry about the double-meaning of the []'s in your solution, and the fact that these: /\m[...]...\M/; /\d[...]...\D/; Will work so differently. Maybe another character like ()'s that takes a list: /\m(<<,[).*?\M(>>,])/;

Re: RFC 145 (alternate approach)

2000-09-05 Thread Nathan Wiger
Eric Roode wrote: > > Unfortunately, as Richard Proctor pointed out, ?m is taken. Perhaps > (?[list|of|openers) and (?]list|of|closers) ? > > Does that look too bizarre, with the lone square bracket in each? > Or does that serve to make it mnemonic (which is my intention)? Actually, I persona

Re: RFC 145 (alternate approach)

2000-09-05 Thread Nathan Wiger
Richard Proctor wrote: > > No ?] should match the closest ?[ it should nest the ?[s bound by any > brackets in the regex and act accordingly. Good point. > Also this does not work as a definition of simple bracket matching as you > need ( to match ) not ( to match (. A ?[ list should specify

Re: RFC 145 (alternate approach)

2000-09-05 Thread Nathan Wiger
Nathan Wiger wrote: > >"normal" "reversed" >-- --- >{__A1( )A1__} That should be: {__A1( )1A__} Why you would delimit text this way I have no idea, but it could still work... -Nate

XML/HTML-specific ?< and ?> operators? (was Re: RFC 145 (alternate approach))

2000-09-06 Thread Nathan Wiger
> It would be useful (and increasingly more common) to be able to match > qr|<\s*(\w+)([^>]*)>| to qr|<\s*/\1\s*>|, and handle the case where those > can nest as well. Something like > > match this with > > not this but >this. I suspect this is going to need a ?[ and ?] of its

Re: XML/HTML-specific ?< and ?> operators? (was Re: RFC 145 (alternate approach))

2000-09-06 Thread Nathan Wiger
David Corbin wrote: > > m:(?['' => '').*(?]): > > or more generically > > m:(?['<\w+>' => '').*(?]): I think these are good; but I do also like the idea of "automatic reversing" by default, since that's a common operation. Let's combine the ideas, as Richard suggests. How about: 1. When a

Re: What's in a Regex (was RFC 145)

2000-09-07 Thread Nathan Wiger
> But you said "lists" up there and that sparked an idea in me ... What > does > > @a =~ /pattern/; > > currently do? AFAICT, nothing useful. > Also, it'd be nice if > > @a =~ s/foo/bar/g; > > did something similar. See RFC 170, "Generalize =~ to a special-purpose assignmen

Re: What's in a Regex (was RFC 145)

2000-09-07 Thread Nathan Wiger
Tom Christiansen wrote: > > carefully consider whether any scant benefit these cutesinesses > might provide can be truly worth further exacerbating the rampant > inscrutability problems (stemming mainly from punctuation in lieu > of alphabetics and from magically implicit targets, arguments, and

Re: What's in a Regex (was RFC 145)

2000-09-07 Thread Nathan Wiger
Mark-Jason Dominus wrote: > > Larry said: > > # Well, the fact is, I've been thinking about possible ways to get rid > # of =~ for some time now, so I certainly don't mind brainstorming in > # this direction. > > That is in > <[EMAIL PROTECTED]> > > which is archived at > > ht

Re: perl6-language-regex summary for 20000911

2000-09-11 Thread Nathan Wiger
> RFC 145: Brace-matching for Perl Regular Expressions (Eric Roode) > > Nathan Wiger suggested a special syntax for matching XML-style > open and close tags. This died in favor of a more general brace-matching construct, ?[ and ?], which could be used in this capacity: /(?[&#

Re: RFC 164 (v2) Replace =~, !~, m//, s///, and tr// with match(), subst(), and trade()

2000-09-14 Thread Nathan Wiger
> What's next, replace the regex syntax with something that more closely > ressembles the rest of Perl? No. > Regexes are a language within the language. And not a tiny one. I know... :-) > So, if regexes are such a completely different sublanguage, I can see > the m// and s/// syntax as just

Re: RFC 164 (v2) Replace =~, !~, m//, s///, and tr// with match(), subst(), and trade()

2000-09-14 Thread Nathan Wiger
> I'm opposed to an obligation to replace m// and s///. I won't mind the > ability to give a prototype of "regex" to functions, or even > *additional* functions, match and subst. As the RFC basically proposes. The idea is that s///, tr///, and m// would stay, seemingly unchanged. But they'd actua

Re: RFC 170 (v2) Generalize =~ to a special "apply-to" assignment operator

2000-09-26 Thread Nathan Wiger
Simon Cozens wrote: > > Looks great on scalars, but... > > @foo =~ shift; # @foo = $foo[0] ? > @foo =~ unshift; # @foo = $foo[-1] ? Yes, if you wanted to do something that twisted. :-) It probably makes more sense to do something like these: @array =~ reverse; @vals =~ sort {

Re: RFC 332 (v1) Regex: Make /$/ equivalent to /\z/ under the '/s' modifier

2000-09-28 Thread Nathan Wiger
> Is $$ the only alternative, or did I miss more? I don't think I've even > seen this $$ mentioned before? $$ is not a suitable alternative. It already means the current process ID. It really cannot be messed with. And ${$} is identical to $$ by definition. > >I still like the idea of $$, as I d

Re: RFC 331 (v1) Consolidate the $1 and C<\1> notations

2000-09-28 Thread Nathan Wiger
> =item * > C<\1> goes away as a special form > > =item * > $1 means what C<\1> currently means (first match in this regex) > > =item * > ${1} is the same as $1 (first match in this regex) > > =item * > ${P1} means what $1 currently means (first match in last regex) Here's the big problem with

Re: Perl 5's "non-greedy" matching can be TOO greedy!

2000-12-14 Thread Nathan Wiger
>The crux of the problem is that non-greedy qualifiers don't affect the >"earliest match" behavior, which makes the matches more greedy than they >really ought to be. > >Here is a simple example: (tested with perl 5.005_03) > > $_ = ""; > ($greedy) = /(b.*d)/;