Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things

We don't need a cat

by John M. Dlugosz (Monsignor)
on Dec 16, 2002 at 21:03 UTC ( [id://220357]=perlmeditation: print w/replies, xml ) Need Help??

This spun off a thread that had a rough start and is already much too deep. I posted there, but then decided to start a new top-level thread.

#include this text


Replies are listed 'Best First'.
Re: We don't need a cat
by theorbtwo (Prior) on Dec 16, 2002 at 22:38 UTC

    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).

Re: We don't need a cat
by grinder (Bishop) on Dec 17, 2002 at 08:54 UTC

    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'
Re: We don't need a cat
by shotgunefx (Parson) on Dec 17, 2002 at 03:26 UTC
    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?


    "To be civilized is to deny one's nature."
Re: We don't need a cat
by dingus (Friar) on Dec 17, 2002 at 09:59 UTC
    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?


    Enter any 47-digit prime number to continue.
Re: We don't need a cat
by Cybercosis (Monk) on Dec 17, 2002 at 08:36 UTC
    A concatenation operator isn't just about "small syntax" as you put it. It's also about how you think about the operation (Perl's supposed to work for/with your brain, right?). If composing a third string of two others works in your head as interpolation, then there's no problem with that, but if you think about it as sticking one string on the end of another, an operator would be more appropriate for that brain-metaphor.


    nemo accipere quod non merere

Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlmeditation [id://220357]
Approved by Mr. Muskrat
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others studying the Monastery: (3)
As of 2024-07-24 00:03 GMT
Find Nodes?
    Voting Booth?

    No recent polls found

    erzuuli‥ 🛈The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.