August 18, 2002 Re: Reverse Operator Overloading | ||||
---|---|---|---|---|
| ||||
Posted in reply to Pavel Minayev | "Pavel Minayev" <evilone@omen.ru> wrote in message news:CFN374868462475694@news.digitalmars.com... > > I guess there's always pow()... > Hm... Maybe a^^b? It looks like a logical xor to me. Regards, Martin M. Pedersen |
August 18, 2002 Re: Reverse Operator Overloading | ||||
---|---|---|---|---|
| ||||
Posted in reply to Patrick Down | "Patrick Down" <pat@codemoon.com> wrote in message news:Xns926D747D2D455patcodemooncom@63.105.9.61... > 2. The author of some math libary can make sure that > all the types that are not commutative have left > associative operators. i.e > > class A { A mul(B b) { } } > class B ( B mul(A a) { } } > > The problem comes when some other programmer now wants to extend the math libary with type C. With the the reverse operators he can get it to work. > > class C > { > C mul(A a) { } > A mul_r(C c) { } > } > > So I'm inclined to vote for option #3. You make a very good point. I'll leave the door open for #3 in case it does become necessary. |
August 18, 2002 Re: Reverse Operator Overloading | ||||
---|---|---|---|---|
| ||||
Posted in reply to Martin M. Pedersen | "Martin M. Pedersen" <mmp@www.moeller-pedersen.dk> wrote in message news:ajp79j$236i$1@digitaldaemon.com... > "Pavel Minayev" <evilone@omen.ru> wrote in message news:CFN374868462475694@news.digitalmars.com... > > > I guess there's always pow()... > > Hm... Maybe a^^b? > It looks like a logical xor to me. It's been proposed as a logical xor for C many times. |
August 19, 2002 Re: Reverse Operator Overloading | ||||
---|---|---|---|---|
| ||||
Posted in reply to Walter | The != operator functions pretty well as a logical xor. Sean "Walter" <walter@digitalmars.com> wrote in message news:ajpa1n$268h$1@digitaldaemon.com... > > "Martin M. Pedersen" <mmp@www.moeller-pedersen.dk> wrote in message news:ajp79j$236i$1@digitaldaemon.com... > > "Pavel Minayev" <evilone@omen.ru> wrote in message news:CFN374868462475694@news.digitalmars.com... > > > > I guess there's always pow()... > > > Hm... Maybe a^^b? > > It looks like a logical xor to me. > > It's been proposed as a logical xor for C many times. |
August 19, 2002 Re: Reverse Operator Overloading | ||||
---|---|---|---|---|
| ||||
Posted in reply to Sean L. Palmer | How about, *^ _* _^ ^_ (^) Although I hate keyboard switching, I suppose powers arn't used that much (but when they are there useful). "Sean L. Palmer" <seanpalmer@earthlink.net> wrote in message news:ajnom1$kfq$1@digitaldaemon.com... > Speaking of **, are there any plans for D to support exponentiation? It's such a basic math function... > > Neither ** nor ^ are good choices for operator since ^ already means xor and > a ** b can be mistaken for a * (*b). > > I guess there's always pow()... > > Sean > > "anderson" <anderson@firestar.com.au> wrote in message news:ajl71t$14of$1@digitaldaemon.com... > > Come to think of it.... > > > > How will... > > > > Matrix ** Integer > > > > be handled? > > > |
August 19, 2002 Re: Reverse Operator Overloading Question (division) | ||||
---|---|---|---|---|
| ||||
Posted in reply to Walter | How will division work? For example will: FLOAT / MATRIX Use the division overload? MATRIX / FLOAT Use the multiplication overloader by rearrangement? Rearranged to: (1/FLOAT) * MATRIX Otherwise I sense there would be problems. |
August 19, 2002 Re: Reverse Operator Overloading | ||||
---|---|---|---|---|
| ||||
Posted in reply to Patrick Down | Parhaps another idea that could easily be implemented later, would be the ability to add overloaded operators to the data types themselves. ie. //File B.d extend int //You can extend int as many time as you want and should be kept in it's related module. { int add(B b) { } } class B { B add(int X) { } B add(B X) { } } //File Main.d import B ... B b b = X + b + X ... Also arrays... //File B.d extend int[] { int[] add(B b) { } } ... One disadvantage of swizzled operator overloading is that it's always bound to be less optimal then a direct method. However as I said, it's not imperative at the moment. |
August 19, 2002 Re: Reverse Operator Overloading Question (division) | ||||
---|---|---|---|---|
| ||||
Posted in reply to anderson | IC now http://www.digitalmars.com/d/operatoroverloading.html "anderson" <anderson@firestar.com.au> wrote in message news:ajqfbu$cin$1@digitaldaemon.com... > How will division work? > > For example will: > > FLOAT / MATRIX > Use the division overload? > > MATRIX / FLOAT > Use the multiplication overloader by rearrangement? > > Rearranged to: > (1/FLOAT) * MATRIX > > > Otherwise I sense there would be problems. > > |
August 19, 2002 Re: Reverse Operator Overloading | ||||
---|---|---|---|---|
| ||||
Posted in reply to Sean L. Palmer | There's no reason we couldn't use text operators. Remember the inline function syntax we played with a while back? MyObj a; OtherObj b; a exp b; // implemented by MyObj.exp(OtherObj) ??? "Sean L. Palmer" wrote: > Speaking of **, are there any plans for D to support exponentiation? It's such a basic math function... > > Neither ** nor ^ are good choices for operator since ^ already means xor and a ** b can be mistaken for a * (*b). > > I guess there's always pow()... > > Sean > > "anderson" <anderson@firestar.com.au> wrote in message news:ajl71t$14of$1@digitaldaemon.com... > > Come to think of it.... > > > > How will... > > > > Matrix ** Integer > > > > be handled? -- The Villagers are Online! villagersonline.com .[ (the fox.(quick,brown)) jumped.over(the dog.lazy) ] .[ (a version.of(English).(precise.more)) is(possible) ] ?[ you want.to(help(develop(it))) ] |
August 19, 2002 Re: Reverse Operator Overloading | ||||
---|---|---|---|---|
| ||||
Posted in reply to Sean L. Palmer | "Sean L. Palmer" <seanpalmer@earthlink.net> wrote in message news:ajpvap$2ri4$1@digitaldaemon.com... > The != operator functions pretty well as a logical xor. Yes, the counter was ^^ added insufficient utility to make it worthwhile. |
Copyright © 1999-2021 by the D Language Foundation