On 16 Oct 2002, Smylers wrote:
: Larry Wall wrote:
:
: > : $x ~& $y # bitwise and
: > : $x ~| $y # bitwise or
: > :
: > : ~!$x # bitwise not
: >
: > I think I like that. Except now we'll get things like:
: >
: > @x ^~|= @y;
: >
: > Hmm...and then there's:
: >
: > $a ~? $b ~: $c
:
: I don't think they're too problematic. Most people shouldn't need to
: know the bitwise stuff, and for those who do a consistent prefix makes
: it easier to learn.
True. In linguistics we would call it a "productive" prefix, meaning you
can generate new words using it.
: It's rare enough to need bitwise things in Perl 5 (outside golf). I'm
: hoping that it'll be even rarer in Perl 6, as better interfaces are
: designed for the things which at present require flipping individual
: bits.
I almost wonder if it's wrong to waste ~ on it...
That would be an argument for b| and b&, I suppose.
: > And what's bitwise xor?
:
: How about keeping caret for xor?
:
: $a ~^ $b # bitwise xor
: $a ^^ $b # logical xor
:
: I don't think those will clash with the hyper operator.
Depends on whether Damain decides he needs ^ as a superposed "exclusive or"
to go with & and |. That would make ^^ a hyper super xor.
: Hmmm. I'm not sure they look sufficiently different from each other
: though. And it does lead to:
:
: @a ^^^ @b
: @a ^~^ @b
:
: The first of those contains a tripled operator (the thing I was trying
: to avoid when I started this suggestion).
We may well make ^ a separable prefix, so you could write @a ^ ^^ @b.
But it still seems a bit confusing to have two different meanings for ^.
: And both of them run the risk of looking like they're underlining
: whatever's on the line above rather than being operators ...
Score one for using !. Binary !! for xor would be snazzy. And Damian
could have binary ! for super xor if he wants it, and if we don't swipe
it for a unary postfix of some sort.
By the way, we could also allow space in an assignment op, so that
@x ^~|= @y;
could be written:
@x ^ ~| = @y;
But I'm not sure that's an improvement...
Larry