August 03, 2002 Re: new idea (bad idea?) | ||||
---|---|---|---|---|
| ||||
Posted in reply to anderson | "anderson" <anderson@firestar.com.au> wrote in message news:aigj6n$2d5d$1@digitaldaemon.com... I was thinking precedence could be done with a number parhaps. > > this a+b 5(vector a, vector b); //Precidence level 5 > this b+a 5(vector a, vector b); //Precidence level 5 (reverse) > this z*x 4(vector z, vector x); //Precedence level 4 > > //Of course there would be a default precedence, so the numbers should only > be used by the experts |
August 03, 2002 Re: new properties for dynamic arrays | ||||
---|---|---|---|---|
| ||||
Posted in reply to Pavel Minayev | Yes, but then virtual calls won't work for them. Sigh. "Pavel Minayev" <evilone@omen.ru> wrote in message news:CFN374676619595486@news.digitalmars.com... class Vector { ... static operator* (Vector a, Vector b) { ... } static operator* (Vector a, int b) { ... } } Short and clear. |
August 03, 2002 Re: new properties for dynamic arrays | ||||
---|---|---|---|---|
| ||||
Posted in reply to Pavel Minayev | "Pavel Minayev" <evilone@omen.ru> wrote in message news:CFN374678967827778@news.digitalmars.com... > On Tue, 30 Jul 2002 16:52:25 +0200 "Sandor Hojtsy" <hojtsy@index.hu> wrote: > > > Conclusion: This reorder idea is Baaad. > > Agreed. I just wanted to show how it _could_ be done. But I definitely don't like it. Yes, reordering will not work. Reordering relies on special properties of integers, which don't even apply to floating point operations. |
August 03, 2002 Re: new properties for dynamic arrays | ||||
---|---|---|---|---|
| ||||
Posted in reply to Walter | On Sat, 3 Aug 2002 14:49:29 -0700 "Walter" <walter@digitalmars.com> wrote:
> Yes, but then virtual calls won't work for them. Sigh.
If one REALLY needs a virtual operator (so far I didn't), he could
just wrap a function call into it:
class Foo
{
Foo op_mul(Foo b) { ... } // this one is virtual!
Foo operator(*) (Foo a, Foo b) { return a.op_mul(b); }
}
Overloaded operators are mostly used for vectors, matrices, and
alike, where perfomance is typically more important. There is
no sence of having a virtual operator+ for vectors. Could anybody
show an example where virtual operators are really needed?
|
August 04, 2002 Re: new idea (bad idea?) | ||||
---|---|---|---|---|
| ||||
Posted in reply to Pavel Minayev | Your probably right. "Pavel Minayev" <evilone@omen.ru> wrote in message news:CFN374717849229282@news.digitalmars.com... > On Sat, 3 Aug 2002 20:49:30 +0800 "anderson" <anderson@firestar.com.au> wrote: > > > I was thing parhaps precedence could be done with a number. > > > > this a+b 5(vector a, vector b); //Precidence level 5 > > this b+a 5(vector a, vector b); //Precidence level 5 (reverse) > > this z*x 4(vector z, vector x); //Precedence level 4 > > > > //Of course there would be a default precedence, so the numbers should only > > be used by the experts > > I think that user-defined operator precedence is just too complex, and mostly unused feature. Does it really worth Walter's time to spend to implement it? |
August 04, 2002 Re: new properties for dynamic arrays | ||||
---|---|---|---|---|
| ||||
Posted in reply to Pavel Minayev | But why not simply have the function call in the first place as the operator? "Pavel Minayev" <evilone@omen.ru> wrote in message news:CFN374721052143982@news.digitalmars.com... On Sat, 3 Aug 2002 14:49:29 -0700 "Walter" <walter@digitalmars.com> wrote: > Yes, but then virtual calls won't work for them. Sigh. If one REALLY needs a virtual operator (so far I didn't), he could just wrap a function call into it: class Foo { Foo op_mul(Foo b) { ... } // this one is virtual! Foo operator(*) (Foo a, Foo b) { return a.op_mul(b); } } Overloaded operators are mostly used for vectors, matrices, and alike, where perfomance is typically more important. There is no sence of having a virtual operator+ for vectors. Could anybody show an example where virtual operators are really needed? |
August 04, 2002 Re: new properties for dynamic arrays | ||||
---|---|---|---|---|
| ||||
Posted in reply to Pavel Minayev | "Pavel Minayev" <evilone@omen.ru> wrote in message news:CFN374721052143982@news.digitalmars.com... >Overloaded operators are mostly used for vectors, matrices, and >alike, where perfomance is typically more important. There is >no sence of having a virtual operator+ for vectors. Could anybody >show an example where virtual operators are really needed? The compare operator when building, say, a generic array sorter. |
August 04, 2002 Re: new properties for dynamic arrays | ||||
---|---|---|---|---|
| ||||
Posted in reply to Walter | On Sun, 4 Aug 2002 08:15:32 -0700 "Walter" <walter@digitalmars.com> wrote:
> The compare operator when building, say, a generic array sorter.
It can always be implemented as a virtual cmp() function.
Besided, you won't need it to be virtual if that array sorter would be
templated.
|
August 05, 2002 Re: virtual static? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Walter | Just wondering what the argument against virtual static members is? I've never read anything against them in books. I'm sure there's a good reason they weren't implemented in C++. So what it the reasoning against virtual static members? Thanks |
August 05, 2002 Re: virtual static? | ||||
---|---|---|---|---|
| ||||
Posted in reply to anderson | Because it doesn't make sense to call a static method through an object reference? But how else do you get the compiler to "figure out" which version of the function to call? Seems you either want a static function (non-virtual) or a virtual member function. How would you use one if you had the capability? Sean "anderson" <anderson@firestar.com.au> wrote in message news:aikj9d$2bh1$1@digitaldaemon.com... > Just wondering what the argument against virtual static members is? I've never read anything against them in books. I'm sure there's a good reason they weren't implemented in C++. So what it the reasoning against virtual static members? > > Thanks |
Copyright © 1999-2021 by the D Language Foundation