On Fri, 11 Oct 2002, Jonathan Scott Duff wrote: : On Fri, Oct 11, 2002 at 03:21:38PM +0100, Aaron Crane wrote: : > Vaguely heretical, I know, but I'd be inclined to do something like this: : > : > Perl 5 Proposed Perl 6 : > $x && $y $x & $y : > $x || $y $x | $y : : Larry just added nice character doubling ops to be more consistent and : here you want to take two of them away? :-) I doubt I'd muck with the doubled ones. I'm wondering whether the single ones could indicate parallel streams. We had the difficulty of specifying whether the C<for> loop should terminate on the shorter or the longer stream. We could say that | terminates on the longer, and & on the shorter. Possibly there's some relationship with any() and all() in there as well. The | could generally be construed as a comma that doesn't guarantee ordering. So cases could be written when 1 | 2 | 3 {...} as well as with comma. Saying when 1 & 2 & 3 {...} might be short for when all(1,2,3) {...} : > $x & $y bitand($x, $y) : > $x | $y bitor($x, $y) : > : > Using functions instead of operators for these operations seems reasonable : > to me given how often they're useful. : : How about these? : : $x band $y : $x bor $y : : Of course, then people will probably expect these too: : : $x bshl $y : $x bshr $y : $x bxor $y : : Hrm ... : : sysopen(FOO,"foo", O_WRONLY bor O_CREAT bor O_TEXT) : sysopen(FOO,"foo", bor O_WRONLY, O_CREAT, O_TEXT) : : :-( : : As long as we're in fantasy-land, how about these? : : $x .& $y : $x .| $y I was thinking more along the lines of: $x &&& $y $x ||| $y But then there's ~ vs ~~~ too. The triple syntax at least has the virtue of the visual metaphor of doing a bunch of ANDs or ORs in parallel. But it's kind of odd to write ~~~$x for a one's complement. Anyone else want to be UNSUBSCRIBED IMMEDIATELY? :-) : Those look like bit operations to me :-) : : > I'm not especially fond of the names bitand and bitor, but they're : > accurate, reasonably short, and have prior art in C and C++. : : Not all prior art is necessarily good art :-) : : > Two things about this proposal: : > : > * This leaves && and || available for other purposes, but I can't : > off the top of my head think of anything else I'd want them for. : : Then why muck with them? Just munge the bitwise operators. : : > * Does this make it harder to write overloaded bitwise ops for your : > classes? : : No harder than it was before especially given that you can warp the : syntax however you please. No warpage necessary. All operators can be named as functions with operator: on the front. Larry