On the one hand, you're right, a concatination operator is redundant, given interpolation. On the other hand, TMTOWTDI.
Somtimes, I just don't want to have to write somthing in terms of interpolation instead of concatination, even if they are properly the same thing. (They are, in fact, completly the same thing.)
So my vote is still for ~ being the concat operator. Which is good, because the thread on perl6-language is good and dead, which is what I suggest this thread becomes. This is one of those things that could easily be argued about until the end of time -- almost every possible view has good things and bad things going for it.
Warning: Unless otherwise stated, code is untested. Do not use without understanding. Code is posted in the hopes it is useful, but without warranty. All copyrights are relinquished into the public domain unless otherwise stated. I am not an angel. I am capable of error, and err on a fairly regular basis. If I made a mistake, please let me know (such as by replying to this node).
| [reply] [Watch: Dir/Any] [d/l] |
As for string concatenation operators, I would like to draw your attention to a couple of points discussed last month in p6-language:
Reference: pdcawley's most excellent summary.
I would say we are in need of a concatenation operator. I don't always want to interpolate within a string to join things together. And using join to join two scalars together seems cumbersome.
print@_{sort keys %_},$/if%_=split//,'= & *a?b:e\f/h^h!j+n,o@o;r$s-t%t#u'
| [reply] [Watch: Dir/Any] |
Yes we do. I would prefer writing $foo ~ $bar rather than "${foo} ${bar}" and I am sure therere are others that would too. (Actually I would rather write $foo . $bar but that isn't going to happen.) Technically speaking, we don't "need" many things. To me, the flexibility is one of the things that makes perl, Perl. Sometimes I cat, sometimes I interpolate.
I haven't kept up on perl6 development lately, but isn't there going to be a unary version ( ~@array ) as well? or has this changed?
-Lee
"To be civilized is to deny one's nature." | [reply] [Watch: Dir/Any] |
We may not need a cat but we really do need an append (i.e the p6 equivalent of $string .= $appended_text) and if you have no cat operator then you can't have a nice append operator related to it. I suppose that if you rule that interpolation ("") is the way to go then you could go for "= but I think that would break many colouring editors not to mention cause a lot of people to get very confused.
Of course if you define cat as join('', list) then it might be reasonable to create an append($target, list) function but that does rather add to the verbiage AND change the way you look at the operation. To me, at least, opeators are cheap and quick functions are generally slower and more expensive. concatenate and append should IMO be looked on as cheap and quick because they are.
Another possibility that I just thought of while writing this is that append could be written using print $target list but that opens a whole can of mainainability worms as $target could either be a filehandle or a string and I see no easy way to make it clear which it is in a particular context.
PS For those who understand pantomime, does this thread sound a little familiar?
Dingus Enter any 47-digit prime number to continue. | [reply] [Watch: Dir/Any] [d/l] |
| [reply] [Watch: Dir/Any] |