Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer

Re^2: ?: = Obfuscation?

by blazar (Canon)
on Dec 02, 2006 at 13:28 UTC ( #587394=note: print w/replies, xml ) Need Help??

in reply to Re: ?: = Obfuscation?
in thread ?: = Obfuscation?

From a language design point of view, there are certainly some problems with ?:, some of which have been pointed out here. Our approach in Perl 6 has been to try to fix the problems without throwing out the whole idea. One of the problems is simply that it's too hard to see the bits of ?:, so we made the bits bigger. In Perl 6 you use ??!! instead. This also plays into the Perl 6 principle that ? and ! are generally preferred to ask whether things are true or false. There is no natural association between : and the concept of falseness.

Speaking of the ternary operator (whatever it' spelt), I've sometimes felt the need to make it... ehm... quaternary. Specifically, in cases in which I wanted it to return something different on true, false (but defined) and undefined first argument respectively. Now, before pointing out that there are ways around, let me tell you that I know there are tons in Perl 5 and presumably even more so in Perl 6. But I'd also like a syntactically sweet enough solution out of the box, and I wondered whether an optional <c<!!</c> may trigger that:

my $wanted = $cond ?? $true !! $false !! $undefined;

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://587394]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (8)
As of 2017-07-20 20:58 GMT
Find Nodes?
    Voting Booth?
    I came, I saw, I ...

    Results (315 votes). Check out past polls.