Syntactic Confectionery Delight PerlMonks

### Re^6: Burned by precedence rules (== true)

 on Dec 30, 2008 at 20:49 UTC ( #733341=note: print w/replies, xml ) Need Help??

in reply to Re^5: Burned by precedence rules (== true)
in thread Burned by precedence rules

In Perl 6 we can use positive boolean context, which helps readability a little:
```if ?\$x == ?\$y {...}
if ?\$x != ?\$y {...}
We can use junctions, which again helps the different case more than the same case:
```if not \$x ^ \$y {...}
if \$x ^ \$y {...}
or if you prefer:
```if !one(\$x,\$y) {...}
if one(\$x,\$y) {...}
That's probably enough ways to do it...

Replies are listed 'Best First'.
Re^7: Burned by precedence rules (eqv)
by tye (Sage) on Dec 31, 2008 at 02:14 UTC

Nah. Clearly this demonstrates the utility of a few "Boolean comparison" operators:

```    if \$isFree ?= \$isEasy
if \$isOne !?= \$isOther

or  die "Inconsistent state";

system \$verifyUser
or   die "You are not just either a User or an Admin";

;)

- tye

Well, we can't use eqv because we already use that for something else, but we do have a Boolean not-equal already:
```    \$x ?^ \$y
What we don't have is a Boolean equal. I thought about adding:
```    \$x ?= \$y
but people would probably think that means:
```    \$x = \$x ? \$y;
which is nonsense, but they'd still think it. :-)

Anyway, the utility is not worth the extra complexity, in my opinion. Comparing two Booleans for equivalence is an odd enough thing to do that I don't mind if it looks a little odd.

What about saying that !( potential boolean operator ) means the boolean negation of the boolean operator? That would naturally give you the logical operators !&& (nand), !|| (nor) and !^ (not xor). The last would, of course, be Boolean equals.

(I can't believe I just suggested that.)

Note that I did include a winky smiley. But I saved the clincher argument for now: Perl 6 is becoming so like VB, it will be very surprising to VBers when the purpose of eqv is so different. :-D

- tye

Create A New User
Node Status?
node history
Node Type: note [id://733341]
help
Chatterbox?
 [choroba]: someone told me to use perl instead of sed for something, and several years later, I'm developing a huge Tk application [Discipulus]: choroba started in primary school to get some advantage in the future.. [choroba]: nono, I programmed in Basic at the primary school, on my Commodore 116/16 [Discipulus]: ;=) [choroba]: then learned some assebly on the same machine, then moved to my father's PC (XT with a Hercules card), used Turbo Pascal a lot [choroba]: I started with *nix at the University, we had some Sparcs and Linux machines [choroba]: that was around 1994 or 95 hippo actually introduced Linux to his university. Discipulus mmh will be a fun meditation: How I started with computers and programming.. [Discipulus]: bravo hippo! well done

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (11)
As of 2018-06-22 09:37 GMT
Sections?
Information?
Find Nodes?
Leftovers?
Voting Booth?
Should cpanminus be part of the standard Perl release?

Results (123 votes). Check out past polls.

Notices?