Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Re: Re: Re: NO PERL 6

by elusion (Curate)
on Dec 09, 2002 at 16:47 UTC ( #218584=note: print w/ replies, xml ) Need Help??


in reply to Re: Re: NO PERL 6
in thread NO PERL 6

Just a quick note. _ is no longer being used for the concatenation operator, now it's ~.

"hello " ~ "world"; $str ~= "!!!"; # which is different from =~ (if =~ isn't changed)
Also, the "." syntax has one big advantage: topics. When calling a method on the topic ($_ (also $self in OO -- see article on perl.com)), a lone dot looks much better than a lone arrow. .method vs. ->method And it fits my brain better for assignment.

elusion : http://matt.diephouse.com


Comment on Re: Re: Re: NO PERL 6
Select or Download Code
Re: Re: Re: Re: NO PERL 6
by dbp (Pilgrim) on Dec 09, 2002 at 19:31 UTC
    Oh man. This ~= vs =~ should quickly catapult to the "most common dumb-ass Perl coding mistake" position when Perl 6 is released.

      I don't see this as any worse than the silent errors created by typing $f =~ $f when what you meant was $f = ~$f? Eg.

      c:\test>perl -e "for $f ( @a = qw/0 1 2.3 fred . ''/) { print $f =~ $f +, '-', $f = ~$f, $/; }" 1-╧ 1-╬ 1-═╤╠ 1-ÖìÜ¢ 1-╤ 1-╪╪

      Of course, it could compound the problem.

      Personally, it seems that the search for an alternative to '.' for string catenation is avoiding the obvious choice for sake of not being "me too".

      If the use of '+' and '+=' for this is undesirable for syntactic reasons, I wonder if its actually necessary to have a catenation char--why not simply use abuttment? Is there any situation when

      $string = "dsadfkjasdkhakhds dhf sahd fsd " "sdshsa ashjashjas asjhasjhasdh"; $str = 'Fred is ' $num " years old\n";

      would be ambiguous?

      For an alternative to $str .= $more how about $str "= $more;?


      Okay you lot, get your wings on the left, halos on the right. It's one size fits all, and "No!", you can't have a different color.
      Pick up your cloud down the end and "Yes" if you get allocated a grey one they are a bit damp under foot, but someone has to get them.
      Get used to the wings fast cos its an 8 hour day...unless the Govenor calls for a cyclone or hurricane, in which case 16 hour shifts are mandatory.
      Just be grateful that you arrived just as the tornado season finished. Them buggers are real work.

        Larry recently addressed both these points. +, he thinks, would be a bad choice for concatination. I note even VB, which does use + as it's concat operator most of the time, has an & operator, for where it's unclear if you want to add, or simply concatinate two strings that happen to be numeric. Larry s Post

        As far as using abjunctation as the concat operator (IE the no-operator operator), that "can never happen in perl", since there are quite a number of things that have different meaning if perl is expecting a TERM or an OP, and will only be more in perl6. I can't seem to find Larry's post on this, but for example, << as here-doc (term) vs. shift-left (op).


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

        print $fh $foo;

        Should that print $foo to the file handle $fh, or print $fh . $foo to STDOUT? sort and exec are other function who may have an optional first argument that isn't followed by a comma.

        Abigail

      Which is why the "smart-match" operator (what the =~ regex binding operator is changing to) is changing to ~~ when/if the concatination operator becomes ~.


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

        Which is in turn why the recent thread dealing with moving operators around was one of the longest I've seen on perl6-language by quite some margin, and I don't expect anything to surpass it for a good while yet.
      Hmmm, is that worse than += vs =+ and -= vs =- which is already possible in Perl (as well as in C and a bunch of other languages)?

      Abigail

      We don't need a concatenation operator at all. Just use the new-improved string interpolation: "$(expression-1)$(expression-2)". In fact, since most explicit cases of concatenation are for when interpolation isn't good enough (e.g. an expression not a single variable) this will take care of most of today's uses.

      When you want to make it clear that you're concatenating something, why have a small syntax? Seems to me you are asking for big syntax, to emphasize the thing. So just use join with an empty first argument (no separate cat function needed.

      —John

      I started a new top-level thread here. This is already too deep!

      Edit by tye to fix link

        There wasn't there... something go wrong somewhere?

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://218584]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (8)
As of 2014-12-29 14:06 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (188 votes), past polls