Re: [RFC PATCH 0/2] New operator: exists-or
[Posted November 16, 2011 by corbet]
| From: |
| Tom Christiansen <tchrist-AT-perl.com> |
| To: |
| ilmari-AT-ilmari.org (Dagfinn Ilmari =?utf-8?Q?Manns=C3=A5ker?=) |
| Subject: |
| Re: [RFC PATCH 0/2] New operator: exists-or |
| Date: |
| Fri, 11 Nov 2011 06:53:13 -0700 |
| Message-ID: |
| <16149.1321019593@chthon> |
| Cc: |
| perl5-porters-AT-perl.org |
| Archive-link: |
| Article, Thread
|
ilmari@ilmari.org (Dagfinn Ilmari =?utf-8?Q?Manns=C3=A5ker?=) wrote
on Fri, 11 Nov 2011 11:07:18 +0100:
> Tom Christiansen <tchrist@perl.com> writes:
>> Perl already has a \\ operator:
> That's only valid in term context, not operator context. If you'd
> bothered to read the patch (specifically the toke.c part) you would have
> seen that this _only_ makes previously-invalid syntax ("Backslash found
> where operator expected") valid.
That isn't my point.
I wasn't saying that Perl already had an infix binop called "\\". I was
saying that "\\" already did something as an operator, which it does. It
happens to be prefix unop doubly applied, just as one can do with "!!" or
"~~". Doubled operators should have some relationship with their single
versions, or else we disconnect.
The unaries below count as TERMs not as OPERATORs in the parse. But
lexically they are still operators, and the meanings of the single are
closely tied up to the meanings of the doubles.
Double Double Is single
Arity Single Double in C? in Perl? related to double?
Unary ! !! yes yes yes
Unary ~ ~~ yes yes yes
Binary ~ ~~ no yes NO!
Binary & && yes yes yes
Binary | || yes yes yes
Binary ^ ^^ no no n/a
Unary % %% no no n/a
Binary % %% no no n/a
Unary * ** yes no yes
Binary * ** no yes yes
Unary + ++ yes yes yes
Unary - -- yes yes yes
Binary , ,, no no n/a
Binary < << yes yes yes
Binary > >> yes yes yes
Binary = == yes yes yes
Binary . .. no yes NO!
Unary / // no yes YES!
Binary / // no yes NO!
Unary \ \\ yes yes yes
Binary \ \\ no no n/a
Binary x xx no no n/a
Don't you see the problem? "\\" has nothing to with "\"!!! That's a
design flaw, because it (further) corrupts the reinforcement principle
that doubling something gives.
Yes, Perl already broke that. I can live with ".." because it has
precedent in common usage. But "//" was a glaring error, because by
analogy with "*" and "**", it should have taken the log of its left
operand using the base of its right. It violates the principle of least
surprise. It is out of step with "+" and "++", and all the rest of them.
But there's an even worse problem. A "\" is **very** special character
in all C-derived languages. It escapes things. It does this in Perl,
preventing things from having special meaning in regexes and preventing
variables from interpolating into strings or lists.
To even talk about "\\" makes your mind scream, because you lex
that as a single literal backslash: indeed, that is precisely
what the "\\" or '\\' or /\\/ means: a single backslash. This is
a towering metarule in all C-derived languages. You want to break that,
cast it all aside for no good reason.
Trying to use a backslash in a way that runs counter to the lexical texture
of the language is as disrespectful of that lexical texture as was
Microsoft's idiotic decision to use backslash as a path separator, forever
cursing programmers to have to double it up any time they want to use it.
When a language has single guiding designer, whether Dennis and Ken for C,
or Larry in Perl, you don't get these paradoxical and counterintuitive
warts that make no sense taken in the larger context of that language.
When you have a hundred million people who *do*not*share* the lexical
sensitivity and sensibility of the language's designer adding oh-by-way
exceptions and special corner cases, you run the risk of corrupting the
self-reinforcing *beauty* of that original vision with disruptive noise,
destroying the unifying aesthetic by cluttering it with abnormal exceptions
that break all the metarules of that language.
It violates the principle of least surprise.
It stops hanging together.
It stops making sense.
Can't you see how *ugly* that is?
Can't you see how undesirable that is?
--tom
(
Log in to post comments)