You're viewing a comment by Josh ben Jore and its responses.

November 30, 2009, 22:05

Hi,
I'm appalled at these "operators." These are not "operators" but rather anti-readable, anti-maintainable bits of syntax.

Your "eskimo" operator is visually syntactically invalid and is better off being forgotten. The readable form of

perl -ne '}{ print $. }'

ought to be

perl -ne 'END { print $. }'

which still uses a punctuation variable but that can be looked up directly in the perlvar manual page.

Your goatse is disgusting, both for bringing it up in conversation and for removing the appropriate white space. The perlop manual documents:

a list assignment in scalar context returns the number of elements produced by the expression on the right hand side of the assignment.

That is,

$count = () = ...

is an amalgam of the assignment

() = ...

which itself is a special case of

( $foo, $bar ) = ...

and the simpler

$count = ...

. This could plausibly be more readably written with spaces around the embedded empty list. I'm really ambivalent about suggesting even this because it's trading on a presumably less-well-known effect and a special case of syntax.

$count = () = ...

I would like to be upset with the turtle operator but I'm overwhelmed by the other flagrant violations of good sense nearby.

Inchworm operator

~~

is bankrupt for several reasons and should not appear in any person's code for several reasons. There is a perfectly readable operator

scalar

which does the right thing. "Inchworm" is two unary ~ bitwise negation operators. It casts the input first to string or integer (and breaks objects, floats, arrays, hashes, etc). For long strings, ~ asks for a negated copy. Perhaps that's expensive.

Separately, your ~(~(expr)) inchworm only even means what you intended in places where the parser expected an expression. In Perl 5.10 there is a separate smartmatch operator written as ~~ which is parsed in places expecting a binary operator.

print ~~$x; # inchworm
print $y ~~ $x; # smartmatch

"Inchworm on a stick" continues the abuse by invoking details of the representation of integers in memory. Are you for real?! Perhaps a more readable way to get the value of an integer minus one is:

$x - 1

.

"Space station" -+- is the three unary operators -, +, and -. I continue to be incredulous that you even posted this. I'm forced to guess a little at what's going on here. The first, inner - either negates the inner integer or adds a '-' character on the beginning of the string:

"-foo" eq -"foo"

.
The middle + is unused except as a fake to the parser to avoid writing the "--" operator:

+"-foo" eq "-foo"

. The outer '-' re-negates the inner value except that a string already starting with "-" turns into "+".

-"foo" eq "-foo"
-( -"foo" ) eq "+foo"

Reply To This Comment

(why do I need your e-mail?)

(Your twitter name, if you have one. (I'm @pkrumins, btw.))

Type the first letter of your name: (just to make sure you're a human)

Please preview the comment before submitting to make sure it's OK.