Re: Operator precedence fiddling

2011-12-23 Thread Stefan O'Rear
On Fri, Dec 23, 2011 at 10:59:58PM +1100, Kris Shannon wrote: > sub infix: ($a, $b = ($a foo 2 * 3 - $a)) is tighter(&infix:<*>) > { > $a == 0 ?? 1 foo 2 * 3 !! $a + $b > } > > say 1 foo (2 * 3); > # 7 > say (1 foo 2) * 3; > # 9 > > say 1 foo 2 * 3; > # 9 > > say infix:(1); > # Niecza: 7 >

Re: Operator sleuthing...

2009-01-27 Thread Larry Wall
On Thu, Jan 15, 2009 at 10:52:55PM -0800, Mark Lentczner wrote: > I'm re-working my "Periodic Table of the Operators" chart to be up-to- > date. I did the first major pass based on S03-operators. However, the > last few days I've been plowing through STD.pm and have discovered that > there som

Re: Operator sleuthing...

2009-01-15 Thread Jon Lang
Mark Lentczner wrote: > STD has sym<;> as both an infix operator ( --> Sequencer), and as a > terminator. > ?? Which is it? Since I think most people think of it as a statement > terminator, I plan on leaving it off the chart. It is both. Examples where it is used as an infix operator include:

Re: operator vs function

2008-10-30 Thread Larry Wall
On Thu, Oct 30, 2008 at 05:41:11PM +0100, Moritz Lenz wrote: : Xiao Yafeng wrote: : > Off the top of one's head, since there is no particular difference between : > an operator and a function, can I see a function as a operator: : > : > (1, 2, 3, 4) >>elems<<(2, 3, 4, 5) #(2, 2, 2, 2) : >

Re: operator vs function

2008-10-30 Thread Moritz Lenz
Xiao Yafeng wrote: > Off the top of one's head, since there is no particular difference between > an operator and a function, can I see a function as a operator: > > (1, 2, 3, 4) >>elems<<(2, 3, 4, 5) #(2, 2, 2, 2) > (1, 2, 3, 4) >>shift<<(2, 3, 4, 5) #(2, 3, 4, 5) But remember

Re: Operator overloading/Inheritance from built-in types?

2006-10-05 Thread David Brunton
iginal Message From: David Brunton <[EMAIL PROTECTED]> To: perl6-users@perl.org Sent: Thursday, October 5, 2006 4:01:34 PM Subject: Re: Operator overloading/Inheritance from built-in types? Hopefully the following will help. If I've missed the thrust of your questions, feel free to d

Re: Operator overloading/Inheritance from built-in types?

2006-10-05 Thread David Brunton
Hopefully the following will help. If I've missed the thrust of your questions, feel free to disregard while someone else improves on my answer :) I only overloaded the infix:<+> operator, but it should give you an idea. I would write the class comme ça: use v6-alpha; class Register { has

Re: Operator sub names are not special

2005-09-03 Thread Yuval Kogman
On Sat, Sep 03, 2005 at 11:45:33 +0300, Yuval Kogman wrote a lot. I'd like to summarize: * if operators are not special than they are defined in perl 6 (maybe) * if operators are defined in terms of other operators, then overriding an operator may interfere with t

Re: Operator sub names are not special

2005-09-03 Thread Yuval Kogman
On Thu, Sep 01, 2005 at 17:12:51 +, Luke Palmer wrote: > On 9/1/05, Yuval Kogman <[EMAIL PROTECTED]> wrote: > > On Wed, Aug 31, 2005 at 13:43:57 -0600, Luke Palmer wrote: > > > Uh yeah, I think that's what I was saying. To clarify: > > > > > > sub foo (&prefix:<+>) { 1 == 2 }# 1 and 2

Re: Operator sub names are not special

2005-09-01 Thread Luke Palmer
On 9/1/05, Yuval Kogman <[EMAIL PROTECTED]> wrote: > On Wed, Aug 31, 2005 at 13:43:57 -0600, Luke Palmer wrote: > > Uh yeah, I think that's what I was saying. To clarify: > > > > sub foo (&prefix:<+>) { 1 == 2 }# 1 and 2 in numeric context > > foo(&say); # nothing printed > > > > But

Re: Operator sub names are not special

2005-09-01 Thread Yuval Kogman
On Wed, Aug 31, 2005 at 13:43:57 -0600, Luke Palmer wrote: > Uh yeah, I think that's what I was saying. To clarify: > > sub foo (&prefix:<+>) { 1 == 2 }# 1 and 2 in numeric context > foo(&say); # nothing printed > > But: > > sub foo (&prefix:<+>) { +1 == +2 } > foo(&say);

Re: Operator sub names are not special

2005-08-31 Thread Luke Palmer
On 8/31/05, Yuval Kogman <[EMAIL PROTECTED]> wrote: > On Wed, Aug 31, 2005 at 04:56:25 -0600, Luke Palmer wrote: > > > (That is, lexically binding &prefix:<+> does not change things in > > numeric context; only when there's actually a + in front of them) > > Unless you override &prefix:<+> ? > >

Re: Operator sub names are not special

2005-08-31 Thread Yuval Kogman
On Wed, Aug 31, 2005 at 04:56:25 -0600, Luke Palmer wrote: > (That is, lexically binding &prefix:<+> does not change things in > numeric context; only when there's actually a + in front of them) Unless you override &prefix:<+> ? sub foo (&prefix:<+>) { +1 } -- () Yuval Kogman <[EMAIL PROTECT

Re: operator

2005-01-30 Thread Luke Palmer
Markus Laire writes: > [EMAIL PROTECTED] kirjoitti: > >Please, > >I have a question if exists in Perl somethink like keyword > >'operator' in C++ ? > > That will exist in perl6. And to quite a larger extent. Not only can you overload existing operators, you can make up whatever operator name you

Re: operator

2005-01-29 Thread Markus Laire
[EMAIL PROTECTED] kirjoitti: Please, I have a question if exists in Perl somethink like keyword 'operator' in C++ ? That will exist in perl6. for example we can write in C++ : class A { A() { printf("Constructor of object class A\n"); } ~A() { printf("Destructor of object class A\n"); } }; A &opera