Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

why ~ for xor?

6 views
Skip to first unread message

Michal Wallace

unread,
Aug 10, 2003, 11:43:05 PM8/10/03
to perl6-i...@perl.org

Out of curiosity, why does ~ map to both
unary bitwise-not and binary bitwise-xor
in imcc?

I was expecting xor to be ^ and ^^

Sincerely,

Michal J Wallace
Sabren Enterprises, Inc.
-------------------------------------
contact: mic...@sabren.com
hosting: http://www.cornerhost.com/
my site: http://www.withoutane.com/
--------------------------------------


Leopold Toetsch

unread,
Aug 11, 2003, 5:43:23 AM8/11/03
to Michal Wallace, perl6-i...@perl.org
Michal Wallace <mic...@sabren.com> wrote:

> Out of curiosity, why does ~ map to both
> unary bitwise-not and binary bitwise-xor
> in imcc?

> I was expecting xor to be ^ and ^^

Perl6ism at some time IIRC. I stopped following the various operator
threat^Hds in p6l. But if they are fixed, we should probably go with
Perl6 operators, because they are more complete.

Is there a summary somewhere?

> Sincerely,
>
> Michal J Wallace

leo

Thomas Vesper

unread,
Aug 11, 2003, 9:56:17 AM8/11/03
to Michal Wallace, perl6-i...@perl.org
Michal Wallace wrote:
> Out of curiosity, why does ~ map to both
> unary bitwise-not and binary bitwise-xor
> in imcc?
>
> I was expecting xor to be ^ and ^^

See Apocalypse 3 for this.
^ was reclaimed for hyperoperators.
Binary ~ was chosen as replacement since bitwise-not is already somehow
like bitwise xor with only one operand.
And so ~~ became logical xor.

Thomas

Tom Legrady

unread,
Aug 11, 2003, 12:05:13 PM8/11/03
to perl6-i...@perl.org
When the Perl 6 book came out last month, I contacted the authors
because they use a "vector operator", >>+<<, rather than hyper-operator
^. Allison Randall replied:

"The name and the representation changed late last year in
a big operator cleanup, but the functionality is the same."

So what is '^' being used for, if hyper-operators are no more?
Tom Legrady

Michal Wallace

unread,
Aug 11, 2003, 7:19:40 PM8/11/03
to Thomas Vesper, perl6-i...@perl.org


Aha. I remember that now. Thanks. :)

0 new messages