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

Perl6 Operator List, Take 3

11 views
Skip to first unread message

Michael Lazzaro

unread,
Oct 27, 2002, 3:57:43 PM10/27/02
to perl6-l...@perl.org

If \ meant xor, and some of the other discussed changes:

unary (prefix) operators:

\ - reference to
* - list flattening
? - force to bool context
! - force to bool context, negate
not - force to bool context, negate
+ - force to numeric context
- - force to numeric context, negate
~ - force to string context
. - method call on current topic
- unary xor [no cooresponding operator]

++ - preincrement
-- - predecrement

unary (postfix) operators:

++ - postincrement
-- - postdecrement

... - [maybe] same as ..Inf

other postfix operators:

() - (when operator is expected)
[] - array access
{} - hash access

magical whitespace modifier
_ - remove whitespace/newline

hyperoperators:

^ - as prefix to any unary/binary operator, "vectorizes" the operator

binary operators:

+ - * / % ** x xx ~
+= -= *= /= %= **= x= xx= ~=

< > <= >= == != <=>
lt gt le ge eq ne cmp

&& || \\ // - boolean operations
&&= ||= \\= //=
and or xor err

.& .| .\ << >> - bitwise or charwise operations
.&= .|= .\= <<= >>= - (depending on operants)
- [or maybe +& vs ~&, etc.]

?& ?| ?\ - [maybe] bitwise operations on bools (as
in C)
?&= ?|= ?\= - (result is always 1 or 0)

& | \ ! - superpositional operations
&= |= \= - intersection, union, disjunction
all any one none
sum prod cat reduce

~~ !~ - smartmatch, perl5 =~,!~

=> - pair creator
, - list creator
; - "greater comma", list-of-lists creator
: - adverbial
. - method call

.. - range
... - [maybe] range, exclusive of endpoint

= - assignment
:= - binding
::= - binding, but more so

trinary operator:

?? :: - if/else

parens, misc, and quotelike operators

()
[] - [when term is expected]
{} - [when term is expected]

m// - shorthand, "matches"
s/// - shorthand, "substitute"
tr/// - shorthand, "transliterate"

'...' "..." `...` /.../ << >>
q qq qx rx qw
(+ qr ?)

(heredocs) - [exact format unknown]


named unary (prefix) operators, terms, and other assorteds, identified
when possible:

-X - [op] filetest operators

temp - [op]
let - [op]
ref - [op]
defined - [op]
undef - [op]
undef - [term]
exists - [op]
delete - [op]
but - [op] val properties

${ } - [deref] dereference scalarref
@{ } - [deref]
%{ } - [deref]
&{ } - [deref]

... - [term] yada**3
Inf - [term]
Nan - [term]

is - [declar] var properties
-> - [declar] like 'sub'
hash - [declar] force hash context


explicit radix specifications for integers:
0123 - decimal
2:0110 - binary (also b:0110?)
8:123 - octal (also o:123?)
16:123 - hex (also h:123?)
256:192.168.1.0 - base 256
(...etc...)


other uncategorized:

my our - [declar]
map grep
sqrt log sin cos tan (etc...) - math
lc lcfirst uc ucfirst
int ord oct hex bin

Michael Lazzaro

unread,
Oct 28, 2002, 12:06:01 PM10/28/02
to perl6-l...@perl.org

On Sunday, October 27, 2002, at 12:57 PM, Michael Lazzaro wrote:
> .&= .|= .\= <<= >>= - (depending on operants)

s/operants/operands/

Sorry bout that. Typing too fast.

MikeL

Larry Wall

unread,
Oct 28, 2002, 12:41:37 PM10/28/02
to Michael Lazzaro, perl6-l...@perl.org
On Sun, 27 Oct 2002, Michael Lazzaro wrote:
: If \ meant xor, and some of the other discussed changes:

I mislike \ for xor, primarily because it doesn't fit into the current
"escape" mystique of \.

Larry

Austin Hastings

unread,
Oct 28, 2002, 12:51:28 PM10/28/02
to Larry Wall, Michael Lazzaro, perl6-l...@perl.org
Since xor is really low frequency, why not make "xor" mean xor?

$zero = $a xor $a;
$a xor= $b;

$b xor= $a xor= $b xor= $a; # Swap'em

@a ^xor= @b; # Is this right?

=Austin


__________________________________________________
Do you Yahoo!?
Y! Web Hosting - Let the expert host your web site
http://webhosting.yahoo.com/

Jonathan Scott Duff

unread,
Oct 28, 2002, 12:58:46 PM10/28/02
to Larry Wall, Michael Lazzaro, perl6-l...@perl.org

Does xor really need the punctuation? Does xor really need to be a
primitive?

-Scott
--
Jonathan Scott Duff
du...@cbi.tamucc.edu

Michael Lazzaro

unread,
Oct 28, 2002, 1:11:43 PM10/28/02
to perl6-l...@perl.org

On Monday, October 28, 2002, at 09:58 AM, Jonathan Scott Duff wrote:
> Does xor really need the punctuation? Does xor really need to be a
> primitive?

Though bitwise xor is seldom used for most people, other versions are
likely to be more frequent: the 'superpositional' flavor, for example,
is likely to have significant meaning. Same with 'none', I expect.

& | \ !
all any one none

So supporting a punctuation for xor-like operations is more useful than
it might at first appear.

MikeL

Jonathan Scott Duff

unread,
Oct 28, 2002, 1:36:34 PM10/28/02
to Michael Lazzaro, perl6-l...@perl.org
On Mon, Oct 28, 2002 at 10:11:43AM -0800, Michael Lazzaro wrote:
> Though bitwise xor is seldom used for most people, other versions are
> likely to be more frequent: the 'superpositional' flavor, for example,
> is likely to have significant meaning. Same with 'none', I expect.
>
> & | \ !
> all any one none
>
> So supporting a punctuation for xor-like operations is more useful than
> it might at first appear.

Maybe. How do we get at the eigenstates of a superposition? The
punctuation for one and none could go away if could just count the
eigenstates.

Larry Wall

unread,
Oct 28, 2002, 2:55:24 PM10/28/02
to Michael Lazzaro, perl6-l...@perl.org
On Mon, 28 Oct 2002, Michael Lazzaro wrote:

Well, I don't believe in "none" since it's really easy to say !any(), but
exclusive-or can certainly use the punctuation. Or, actually, I'm currently
thinking, non-punctuation. I kept thinking to myself that it's a shame
that x is already taken, and then I looked crosseyed at the // vs \\
proposals, and I realized we have a superposition of / and \ that is
spelled "X". :-)

So at the moment I'm thinking we have

$a X $b # super xor
$a XX $b # logical high precedence xor
$a X= $b # assignment xor
$a +X $b # intbits xor
$a ~X $b # strbits xor
$a ^XX $b # hyper xor
$a xor $b # low precedence xor
+X $a # int complement
~X $a # str complement

Larry

Jonathan Scott Duff

unread,
Oct 28, 2002, 3:08:09 PM10/28/02
to Larry Wall, Michael Lazzaro, perl6-l...@perl.org
On Mon, Oct 28, 2002 at 11:55:24AM -0800, Larry Wall wrote:
> Well, I don't believe in "none" since it's really easy to say !any(), but
> exclusive-or can certainly use the punctuation. Or, actually, I'm currently
> thinking, non-punctuation. I kept thinking to myself that it's a shame
> that x is already taken, and then I looked crosseyed at the // vs \\
> proposals, and I realized we have a superposition of / and \ that is
> spelled "X". :-)

Hmm. I wonder if people aren't going to expect some relationship
between x and X ..

> So at the moment I'm thinking we have
>
> $a X $b # super xor
> $a XX $b # logical high precedence xor
> $a X= $b # assignment xor
> $a +X $b # intbits xor
> $a ~X $b # strbits xor
> $a ^XX $b # hyper xor
> $a xor $b # low precedence xor
> +X $a # int complement
> ~X $a # str complement

And presumably these as well?

$a ^X= $b # hyper assignment xor
$a ^+X $b # hyper intbits xor
$a ^~X $b # hyper strbits xor
$a ^xor $b # hyper low precedence xor
^+X $a # hyper int complement
^~X $a # hyper str complement

Sometimes when I look at stuff like this I start to Cozenify and ask
myself "what language is this again?"

Brent Dax

unread,
Oct 28, 2002, 3:24:17 PM10/28/02
to Larry Wall, Michael Lazzaro, perl6-l...@perl.org
Larry Wall:
# and then I looked crosseyed at the // vs \\ proposals, and I
# realized we have a superposition of / and \ that is spelled "X". :-)

use Perl::Caseless;
print "foo" x 6; #?!?

--Brent Dax <bren...@cpan.org>
@roles=map {"Parrot $_"} qw(embedding regexen Configure)

Wire telegraph is a kind of a very, very long cat. You pull his tail in
New York and his head is meowing in Los Angeles. And radio operates
exactly the same way. The only difference is that there is no cat.
--Albert Einstein (explaining radio)

Paul Johnson

unread,
Oct 28, 2002, 3:15:28 PM10/28/02
to Larry Wall, Michael Lazzaro, perl6-l...@perl.org
On Mon, Oct 28, 2002 at 11:55:24AM -0800, Larry Wall wrote:

> Well, I don't believe in "none" since it's really easy to say !any()

Does that have any implications for "unless"?

--
Paul Johnson - pa...@pjcj.net
http://www.pjcj.net

Michael Lazzaro

unread,
Oct 28, 2002, 4:19:05 PM10/28/02
to Larry Wall, Paul Johnson, perl6-l...@perl.org

On Monday, October 28, 2002, at 01:09 PM, Larry Wall wrote:
> No. "unless" reads well in English. How do your read $a ! $b ! $c?

"nor"? Maybe it's "$a nor $b"?

MikeL

Larry Wall

unread,
Oct 28, 2002, 4:09:37 PM10/28/02
to Paul Johnson, Michael Lazzaro, perl6-l...@perl.org
On Mon, 28 Oct 2002, Paul Johnson wrote:

: On Mon, Oct 28, 2002 at 11:55:24AM -0800, Larry Wall wrote:
:
: > Well, I don't believe in "none" since it's really easy to say !any()
:
: Does that have any implications for "unless"?

No. "unless" reads well in English. How do your read $a ! $b ! $c?
(When I said I don't believe in "none", I was referring to the infix
operator. I think none($a,$b,$c) is okay.)

Larry

Jonathan Scott Duff

unread,
Oct 28, 2002, 4:30:54 PM10/28/02
to Michael Lazzaro, Larry Wall, Paul Johnson, perl6-l...@perl.org

oh no! You've said "nor", so now I have have to ask about "nand" ...

and the next thing you know perl takes over the world of circuit
design. :-)

Austin Hastings

unread,
Oct 28, 2002, 4:37:04 PM10/28/02
to du...@pobox.com, Michael Lazzaro, Larry Wall, Paul Johnson, perl6-l...@perl.org
If you guys start trying to reserve punctuation for XNOR, the next perl
cruise is going to be through the Bermuda Triangle...

=Austin

Graham Barr

unread,
Oct 28, 2002, 5:48:42 PM10/28/02
to du...@pobox.com, Michael Lazzaro, Larry Wall, Paul Johnson, perl6-l...@perl.org
On Mon, Oct 28, 2002 at 03:30:54PM -0600, Jonathan Scott Duff wrote:
> On Mon, Oct 28, 2002 at 01:19:05PM -0800, Michael Lazzaro wrote:
> >
> > On Monday, October 28, 2002, at 01:09 PM, Larry Wall wrote:
> > > No. "unless" reads well in English. How do your read $a ! $b ! $c?
> >
> > "nor"? Maybe it's "$a nor $b"?
>
> oh no! You've said "nor", so now I have have to ask about "nand" ...
>
> and the next thing you know perl takes over the world of circuit
> design. :-)

Then dont forget full tristate logic too :)

Graham.

Simon Cozens

unread,
Oct 28, 2002, 6:00:10 PM10/28/02
to perl6-l...@perl.org
la...@wall.org (Larry Wall) writes:
> : On Mon, Oct 28, 2002 at 11:55:24AM -0800, Larry Wall wrote:
> : > Well, I don't believe in "none" since it's really easy to say !any()
> :
> : Does that have any implications for "unless"?
>
> No. "unless" reads well in English. How do your read $a ! $b ! $c?

You said above that you've prefer to say (presumably) "not any", using
"!any", rather than "none", which makes me suspect you're using "!" as
"not", so I'd read that "a not b not c", which doesn't make amazing
amounts of sense.

--
Wouldn't it be wonderful if real life supported control-Z?

Damian Conway

unread,
Oct 28, 2002, 11:58:57 PM10/28/02
to perl6-l...@perl.org
Scott Duff asked:

> How do we get at the eigenstates of a superposition?

We obviously need another operator! <ducks>

Actually, I think we need a universal method on scalars that
gives the eigenstates of that value. It might be C<$val.eigenstates>
or maybe just C<$val.states>. The method would work on non-superimposed
values as well, in which cases it would just return a list containing
the value itself.



> The punctuation for one and none could go away if could just
> count the eigenstates.

Yes, but this:

if ($x | $y | $z == 7).states == 1 {...}

aren't nearly as nice as this:

if $x ^ $y ^ $z == 7 {...}

which means everyone will probably write:

if none($x,$y,$z) == 7 {...}

which is probably the right solution anyway ;-)


Damian

Jonathan Scott Duff

unread,
Oct 29, 2002, 12:16:29 AM10/29/02
to Damian Conway, perl6-l...@perl.org
On Tue, Oct 29, 2002 at 03:58:57PM +1100, Damian Conway wrote:
> Actually, I think we need a universal method on scalars that
> gives the eigenstates of that value. It might be C<$val.eigenstates>
> or maybe just C<$val.states>. The method would work on non-superimposed
> values as well, in which cases it would just return a list containing
> the value itself.

Sure, but I'd leave the name "eigenstates" just so the casual
programmer knows they're dealing with something from another
universe if they happen to run across it :-)

Juanma Barranquero

unread,
Oct 29, 2002, 4:23:39 AM10/29/02
to perl6-l...@perl.org
On Mon, 28 Oct 2002 13:09:37 -0800 (PST), Larry Wall <la...@wall.org> wrote:

> How do your read $a ! $b ! $c?

"Neither $a nor $b nor $c".

What? Aren't you able to see this invisible "neither" operator just at
the front? ;-)


/L/e/k/t/u

Damian Conway

unread,
Oct 29, 2002, 3:13:19 PM10/29/02
to perl6-l...@perl.org
Scott Duff wrote:

>>Actually, I think we need a universal method on scalars that
>>gives the eigenstates of that value. It might be C<$val.eigenstates>
>>or maybe just C<$val.states>. The method would work on non-superimposed
>>values as well, in which cases it would just return a list containing
>>the value itself.
>
> Sure, but I'd leave the name "eigenstates" just so the casual
> programmer knows they're dealing with something from another
> universe if they happen to run across it :-)

But they're *not*, that's the point. This stuff just ain't that hard.
It's just set theory with a few interesting behaviour variations
that make it act more like natural English.

Much more on this in the next few posts.

Damian

0 new messages