Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Perl operators are "discovered" and not designed?

Tags:

perl

Just reading this page: https://github.com/book/perlsecret/blob/master/lib/perlsecret.pod , and was really surprised with the statements like:

Discovered by Philippe Bruhat, 2012.
Discovered by Abigail, 2010. (Alternate nickname: "grappling hook")
Discovered by Rafaël Garcia-Suarez, 2009.
Discovered by Philippe Bruhat, 2007.

and so on...

The above operators are DISCOVERED, so they are not intentional by perl-design?

Thats mean than here is possibility than perl sill have some random character sequences what in right order doing something useful like the ()x!! "operator"?

Is here any other language what have discovered operatos?

like image 839
kobame Avatar asked Jul 09 '13 22:07

kobame


2 Answers

From the page you linked:

They are like operators in the sense that these Perl programmers see them often enough to recognize them without thinking about their smaller parts, and eventually add them to their toolbox. And they are like secrets in the sense that they have to be discovered by their future user (or be transmitted by a fellow programmer), because they are not explicitly documented.

That is, they are not really their own operators, but they are made up of smaller operators compounded to do something combinedly.

For example, the 'venus' operator (0+ or +0) numifies the object on its left or right. That's what adding zero in any form does, "secret" operator or not.

like image 165
Jakob Weisblat Avatar answered Nov 13 '22 15:11

Jakob Weisblat


Perl has a bunch of operators that do special things, as well as characters that do special things when interpreted in a specific context. Rather than these being actual "operators" (i.e., not explicitly recognized by the Perl parser), think of them as combinations of certain functions/operations. For example ()X!!, which is known as the "Enterprise" operator, consists of () which is a list, followed by x, which is a repetition operator, followed by !! (the "bang bang" operator), which performs a boolean conversion. This is one of the reasons that Perl is so expressive.

like image 38
Vivin Paliath Avatar answered Nov 13 '22 15:11

Vivin Paliath