Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

Re^2: What operator should perl5porters use for safe dereferencing?

by Anonymous Monk
on Jun 01, 2012 at 03:02 UTC ( [id://973665]=note: print w/replies, xml ) Need Help??


in reply to Re: What operator should perl5porters use for safe dereferencing?
in thread What operator should perl5porters use for safe dereferencing?

I think ~ is assigned to regex match already?

No, see perlop

Binary "=~" binds a scalar expression to a pattern match. Binary "!~" is just like "=~" ... Binary "~~" does a smart match between its arguments. Unary "~" performs bitwise negation ""->"" is an infix dereference operator, just as it is in C and C++. nonassoc < > <= >= lt gt le ge
so currently  ~> is a syntax error, you can't have unary operator bitwise-negation follow greater than operator, so  ~> is free and open for use with no possibility of confusion with anything else

Also, neither  > nor ~ nor ~> nor -> are sigils, sigils are  $ % @ * as in  $ro %sham @bo *dynamite

Replies are listed 'Best First'.
Re^3: What operator should perl5porters use for safe dereferencing?
by xiaoyafeng (Deacon) on Jun 05, 2012 at 10:16 UTC
    Thanks for your correction! But the 3 first main usages of ~ is about match. I suggest ?-> is I believe the one of advantages which perl6 is better than perl5 is its consistency. take a look below:
    • ~ means string, so ~$foo change $foo into string context, and $foo1 ~ $foo2 make a concatenation.
    • +/- means numeric, so +$foo change $foo into numeric context and $foo + 3 is doing mathematic operation.
    • and ? means bool, * means global etc.......
    as we see, in perl6, every sigil has its own consistent meaning and easily for learning. I don't say ~> is bad, I just want every new grammar/op adding during perl5 evolved should keep consistent.




    I am trying to improve my English skills, if you see a mistake please feel free to reply or /msg me a correction

      I don't say ~> is bad, I just want every new grammar/op adding during perl5 evolved should keep consistent.

      Too late. Tilde already has a full house of contextual overloads:

      print ~'fred';; ÖìÜø print ~12345;; 18446744073709539270 print ~( 2 != 2 );; 18446744073709551615 print ~~( '2' eq '2' );; 1 ~\'fred';; ¼&#9565;¥&#9474;¥¡Î¤ç&#9552;ã&#9577;פÃÍ

      One more is neither here nor there.


      With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
      Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
      "Science is about questioning the status quo. Questioning authority".
      In the absence of evidence, opinion is indistinguishable from prejudice.

      The start of some sanity?

      as we see, in perl6, every sigil has its own consistent meaning and easily for learning

      ~ is not a sigil. Its not a sigil in perl5 and its not a sigil in perl6. Also, perl5 is not perl6

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others cooling their heels in the Monastery: (6)
As of 2024-03-19 02:43 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found