Re: YA string concat proposal
Uri Guttman wrote: .= could still be left working as that is a complete separate op from method invocation. I see a major potential problem with that. Assuming (which I do) that the equals operator will be overridable, then you'll need to be able to write $obj.='x'; meaning this (as in in C++): $obj.operator=('x'); -- John Porter It's a sky-blue sky The satellites are out tonight let x = x
YA string concat proposal
Ok, time for me to shot down. I've already voiced my views about trying to make addition and concatination into a single operator in a typeless language http://archive.develooper.com/perl6-language%40perl.org/msg06550.html and I think its a losing proposition. So here's something simple. Sort of a fallback proposal in case nothing amazingly clever comes up. cc and ce Perl 5 Perl 6 print foo . bar;print foo cc bar; print 2 . 4;print 2 cc 4; print foo . ($i + 1);print foo cc ($i + 1); $foo .= bar ; $foo ce bar; Its unambiguous and its analgous to eq, ne, gt, get, etc... About the only problem I can think of is if you define a function called cc() or ce(), but we live with that already with gt() and friends. It also has the nice side-effect of preserving '.=' functionality, which I'd rather not lose (especially after having made fun of $foo = $foo . 'bar'; type code). PS It doesn't have to specifically be cc and ce. Just so long as it matches /^[a-z]{2}$/ and /^[a-z]e$/ -- Michael G. Schwern [EMAIL PROTECTED]http://www.pobox.com/~schwern/ Perl6 Quality Assurance [EMAIL PROTECTED] Kwalitee Is Job One I'm going to have to hurt you on principle.
Re: YA string concat proposal
Michael G Schwern wrote: cc and ce Perl 5 Perl 6 print foo . bar;print foo cc bar; print 2 . 4;print 2 cc 4; print foo . ($i + 1);print foo cc ($i + 1); $foo .= bar ; $foo ce bar; It also has the nice side-effect of preserving '.=' functionality, which I'd rather not lose (especially after having made fun of $foo = $foo . 'bar'; type code). While we're brainstorming a wish-list, here's something I've always wanted, a replacement for: $a = $b . $a; Under the above plan, maybe this is: $a ca $b; For concat after? -Nate
Re: YA string concat proposal
On Tue, Apr 24, 2001 at 01:05:24PM -0700, Nathan Wiger wrote: $a = $b . $a; Under the above plan, maybe this is: $a ca $b; For concat after? I'd rather it be called pp for prepend. :-) It's good that we decided to let Larry design the language, otherwise we'd be mired in muck like this for a long time. -Scott -- Jonathan Scott Duff [EMAIL PROTECTED]
Re: YA string concat proposal
On Tue, Apr 24, 2001 at 01:05:24PM -0700, Nathan Wiger wrote: : Michael G Schwern wrote: : : cc and ce : : Perl 5 Perl 6 : print foo . bar;print foo cc bar; : print 2 . 4;print 2 cc 4; : print foo . ($i + 1);print foo cc ($i + 1); : $foo .= bar ; $foo ce bar; : : It also has the nice side-effect of preserving '.=' functionality, : which I'd rather not lose (especially after having made fun of : $foo = $foo . 'bar'; type code). : : While we're brainstorming a wish-list, here's something I've always : wanted, a replacement for: : :$a = $b . $a; : : Under the above plan, maybe this is: : :$a ca $b; : : For concat after? Now this sparks my interest. :) The only think I don't like is: $a ce $b; $a ca $b; because I'm so used to seing $a [char]= $b; I would think of: $a c= $b; but then the ca() idea might not be feasible unless we thought: $a ce= $b; $a ca= $b; was a good idea. -- Casey West
Re: YA string concat proposal
NW == Nathan Wiger [EMAIL PROTECTED] writes: NW$a = $b . $a; NW Under the above plan, maybe this is: NW$a ca $b; substr( $a, 0, 0, $b ) ; $a =~ s/^/$b/ ; just my $.02 on this. i rarely use bare . for concat. as someone else mentioned, it is usually only needed when you have expressions or function calls that don't directly interpolate in . a long . expression with many terms is rare and probably best done with join ''. on the other hand, i use .= all the time and wouldn't like to lose it. schwern idea of ce doesn't work for me as only the op= stuff means assignment and ce would break that (e for = isn't visual enough). .= could still be left working as that is a complete separate op from method invocation. i can live with most any other form of . including none. join is fine for that. uri -- Uri Guttman - [EMAIL PROTECTED] -- http://www.sysarch.com SYStems ARCHitecture and Stem Development -- http://www.stemsystems.com Learn Advanced Object Oriented Perl from Damian Conway - Boston, July 10-11 Class and Registration info: http://www.sysarch.com/perl/OOP_class.html
YA string concat proposal
~ looks like a string to me Larry sycophant that I am. , also looks a little like a string. And is keyboard friendly. Its doubtless naive to suggest it, but why not: Perl 5 Perl 6 --- --- - . + + . ~+ eq ~== ne ~!= gt ~ ge ~= lt ~ le ~= cmp ~= .= ~+= ~=+ (concat after) =~ =~ !~ !~ You can leave aliases for eq, ne, gt... or depreciate them. -But leave precedence as is... Perl 5Perl 6 - $res = $var + $var2; $res = $var + $var2; $name = This . that; $name = This ~+ that; $name = This . $that; $name = This ~+ $that; print Next is . $i + 1;print Next is ~+ $i + 1; $me = $name . getpwuid($); $me = $name ~+ getpwuid($);
Re: YA string concat proposal
On Tue, Apr 24, 2001 at 01:05:24PM -0700, Nathan Wiger wrote: While we're brainstorming a wish-list, here's something I've always wanted, a replacement for: $a = $b . $a; I don't think there's any pressing need for this unless you can show a common case where a prepend op would make things significantly easier. (Postpend (is that a word?) doesn't make things particularly easier either, but people will expect it and its a bit more common case.) -- Michael G. Schwern [EMAIL PROTECTED]http://www.pobox.com/~schwern/ Perl6 Quality Assurance [EMAIL PROTECTED] Kwalitee Is Job One Free beer w/riot!
Re: YA string concat proposal
Uri Guttman wrote: on the other hand, i use .= all the time and wouldn't like to lose it. schwern idea of ce doesn't work for me as only the op= stuff means assignment and ce would break that (e for = isn't visual enough). I was just thinking, too bad that Larry's claiming the colon currently... $str = $a : $b : $i + 1; $a := $b : $c; $name = $p-param('first') : $p-param('last'); Maybe it's just me, but I like that. There is, of course, the possibility others have mentioned which is to make , in a scalar context do something perceived as more useful: $str = $a, $b, $i + 1; $a ,= $b, $c; $name = $p-param('first'), $p-param('last'); But that second one is a little weird. Plus, this: ($a, $b) = ($1 . $2, $3 . $4); Is now not possible. .= could still be left working as that is a complete separate op from method invocation. i can live with most any other form of . including none. join is fine for that. Possible, but my gut reaction is that this could be confusing, especially assuming that you're going to see . all over your code meaning object deref now. -Nate
Re: YA string concat proposal
From: Jonathan Scott Duff [EMAIL PROTECTED] To: Nathan Wiger [EMAIL PROTECTED] Sent: Tuesday, April 24, 2001 4:08 PM Subject: Re: YA string concat proposal On Tue, Apr 24, 2001 at 01:05:24PM -0700, Nathan Wiger wrote: Under the above plan, maybe this is: $a ca $b; For concat after? I'd rather it be called pp for prepend. :-) I'd rather it be spelled $a =. $b; (or $a=.$b, or $a=./index.html; I don't see how any of those are subject to misparse. $a=.5 would be, of couse, but you can disambugate by $a=. 5 or C$a=.5. It's good that we decided to let Larry design the language, otherwise we'd be mired in muck like this for a long time. Yah. And it looks like we're going to be as it is. It's been said elsewhere on these threads: What does changing to . from - buy us? I can see that . is shorter to type then -, but, say, \ would be just as good. I can't really say changing because . is more standard. It isn't standard to C or perl5. It's possible to misparse . as concat with . as a sepperator on version-strings, but that's more of a problem with using it for method-call. -=- James Mastros
Re: YA string concat proposal
On Tue, Apr 24, 2001 at 01:42:43PM -0700, Nathan Wiger wrote: Uri Guttman wrote: on the other hand, i use .= all the time and wouldn't like to lose it. schwern idea of ce doesn't work for me as only the op= stuff means assignment and ce would break that (e for = isn't visual enough). The fastidious ivory tower side of my brain has always disliked the fact that there is .= for append but no =. for prepend. So if I may have c= and =c in Perl 6 I will be happy :-) (and of course cc for the functional non-argument-modifying version) -- $jhi++; # http://www.iki.fi/jhi/ # There is this special biologist word we use for 'stable'. # It is 'dead'. -- Jack Cohen
Regexp::Func (Re: YA string concat proposal)
Stephen P. Potter wrote: Oh, and since it hasn't been mentioned for awhile, I'd still prefer if =~ and !~ went away and were replaced by match(string, [pattern], options), replace(string, [pattern], options) and trans(string, [pattern], options) or some such. This is one place where I think PHP had a really good idea, but missed the mark a little. ereg_* and eregi_* and preg_* and pregi_*, ugghhh... I'm working on Regexp::Func in another vi window that does this very thing right now. Although, the syntax I'm working with is a little different from what you describe above: $result = match /pat/flags, $strings ...; $result = replace /from/to/flags, $strings ...; $result = trade /from/to/, $strings ...; The advantage to this syntax is you can do whole lists inline. See also RFC 164. Suggestions welcome, and anyone wanting to test this *very* welcome (off-list is probably best, this is OT). -Nate