Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Re: Perl5 Language Extension: Definedness-Triggered Shortcut Operators

by martin (Friar)
on Mar 18, 2012 at 11:57 UTC ( [id://960282]=note: print w/replies, xml ) Need Help??


in reply to RFC: Perl5 Language Extension: Definedness-Triggered Shortcut Operators

One syntactical alternative I could think of is:

A &&& B # defined-and A ||| B # defined-or A >>> B # safe arrow

This would be a systematic approach reminiscent of the role of undef in ternary logic -- triple sign, third kind of truth value involved.

I am not sure whether a whole lot of other similar symbols like ^^^ would make as much sense, though, which means we then had to explain why only those mentioned above were there.

  • Comment on Re: Perl5 Language Extension: Definedness-Triggered Shortcut Operators
  • Download Code

Replies are listed 'Best First'.
Re^2: Perl5 Language Extension: Definedness-Triggered Shortcut Operators
by JavaFan (Canon) on Mar 18, 2012 at 12:20 UTC
    A &&& B   # defined-and
    You're not the first. Here's the reason why it's a bad idea:
    $ perl -ce 'A &&& B' -e syntax OK
    It's not worth breaking backwards compatability for this.

      You are right, triple ampersand parses as "boolean and" followed by a "subroutine call sigil". Too bad.

        The odds of there being code in the wild that does $a&&&foo() with no space seem pretty slim to me. It even seems rather unlikely in an obfu. Not that I have personally witnessed p5p be swayed by such arguments before.

        The odds of "$a &&& $b" being non-broken code in the wild seems even slimmer.

        - tye        

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others meditating upon the Monastery: (4)
As of 2024-04-20 16:35 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found