I very much like the spirit behind this proposal, though I'm not sure if : is a good choice as "defined"-modifier. It doesn't have any definedness connotation for me.

Maybe just stick with d? There's no rule that says operators need to be either word or non-word character only: A d|| B etc.

And while you're at it, you can also introduce a prefix meta operator for exists instead of defined: e|| and e&&

FWIW I don't see any problems with having multiple names for the same operator; it's a good way to deal with language change and graceful deprecation.

Update: I should add that Perl 6 has long taken the road of having meta operators, and even type prefixed operators. For example bitwise AND behaves different from strings and numbers, which is there are two operators for them: +& and ~& (the ~ generally stands for strings in Perl 6, concatenation is infix ~, and string context is prefix ~).

Meta operators are more general than that. For example the Z meta op can be applied to infix operators, making them "zip" two lists together:

my @sums = 1, 2, 3 Z+ 30, 20, 10; # 31, 22, 13;

It's a case where an operator consists of both word and non-word characters, and it's not particularly hard to read.


In reply to Re: Perl5 Language Extension: Definedness-Triggered Shortcut Operators by moritz
in thread RFC: Perl5 Language Extension: Definedness-Triggered Shortcut Operators by martin

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.