CRTP in D?

2009-08-19 Thread bearophile
I don't know much C++. Can CRTP be used in D1 too, to improve the performance of some D1 code? http://en.wikipedia.org/wiki/Curiously_Recurring_Template_Pattern Bye, bearophile

Re: CRTP in D?

2009-08-19 Thread grauzone
bearophile wrote: I don't know much C++. Can CRTP be used in D1 too, to improve the performance of some D1 code? http://en.wikipedia.org/wiki/Curiously_Recurring_Template_Pattern Why don't you just go and try? If you hit forward referencing errors when using structs, try classes with final m

Re: CRTP in D?

2009-08-19 Thread bearophile
grauzone: >Why don't you just go and try?< Mostly because C++ isn't one of the languages I know. I don't fully understand that code. Bye, bearophile

Re: CRTP in D?

2009-08-19 Thread downs
bearophile wrote: > I don't know much C++. Can CRTP be used in D1 too, to improve the performance > of some D1 code? > > http://en.wikipedia.org/wiki/Curiously_Recurring_Template_Pattern > > Bye, > bearophile We have this, except we call it "template mixin" :)

Re: CRTP in D?

2009-08-19 Thread div0
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 downs wrote: > bearophile wrote: >> I don't know much C++. Can CRTP be used in D1 too, to improve the >> performance of some D1 code? >> >> http://en.wikipedia.org/wiki/Curiously_Recurring_Template_Pattern >> >> Bye, >> bearophile > > We have this, e

Re: CRTP in D?

2009-08-19 Thread Bill Baxter
On Wed, Aug 19, 2009 at 10:32 AM, div0 wrote: > -BEGIN PGP SIGNED MESSAGE- > Hash: SHA1 > > downs wrote: >> bearophile wrote: >>> I don't know much C++. Can CRTP be used in D1 too, to improve the >>> performance of some D1 code? >>> >>> http://en.wikipedia.org/wiki/Curiously_Recurring_Temp

Re: CRTP in D?

2009-08-19 Thread div0
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Bill Baxter wrote: > On Wed, Aug 19, 2009 at 10:32 AM, div0 wrote: >> -BEGIN PGP SIGNED MESSAGE- >> Hash: SHA1 >> >> downs wrote: >>> bearophile wrote: I don't know much C++. Can CRTP be used in D1 too, to improve the performance of

Re: CRTP in D?

2009-08-19 Thread div0
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Bill Baxter wrote: > On Wed, Aug 19, 2009 at 10:32 AM, div0 wrote: >> -BEGIN PGP SIGNED MESSAGE- >> Hash: SHA1 >> >> downs wrote: >>> bearophile wrote: I don't know much C++. Can CRTP be used in D1 too, to improve the performance of

Re: CRTP in D?

2009-08-19 Thread bearophile
div0: > Mixins do pretty much same thing but in reverse, mixins pull stuff right > into the class, and with a mixin it's the class which is imposing the > meta interface on the mixin. > > As you pointed out though, CRTP nukes your inheritance slot in D, so > you'd generally prefer mixins in D. CR

Re: CRTP in D?

2009-08-19 Thread Saaa
> Mixins can be used to do a lot (most? all?) of things CRTP is used for: > > class Class(alias MixMe) > { > mixin MixMe impl; > ... > void doSomething { > impl.doIt(); > } > } > where can I read about class parameters?

Re: CRTP in D?

2009-08-19 Thread Bill Baxter
On Wed, Aug 19, 2009 at 2:59 PM, Saaa wrote: > >> Mixins can be used to do a lot (most? all?) of things CRTP is used for: >> >> class Class(alias MixMe) >> { >>   mixin MixMe impl; >>   ... >>   void doSomething { >>         impl.doIt(); >>   } >> } >> > > where can I read about class parameters?

Re: CRTP in D?

2009-08-19 Thread Saaa
"Bill Baxter" wrote in message news:mailman.344.1250719235.14071.digitalmars-d-le...@puremagic.com... On Wed, Aug 19, 2009 at 2:59 PM, Saaa wrote: > >> Mixins can be used to do a lot (most? all?) of things CRTP is used for: >> >> class Class(alias MixMe) >> { >> mixin MixMe impl; >> ... >> void

Re: CRTP in D?

2009-08-20 Thread Kagamin
bearophile Wrote: > grauzone: > >Why don't you just go and try?< > > Mostly because C++ isn't one of the languages I know. I don't fully > understand that code. There's really not much to understand there. The difference from mixin is that Base can inherit an interface so that Derived exposes

Re: CRTP in D?

2009-08-20 Thread John C
div0 Wrote: > > > While we're on the subject, is it possible to mixin in a tuple? > Doesn't seem like you can... > > class C(M...) { > mixin M; > } > > Doesn't work. import std.typetuple; class C(M...) { mixin TypeTuple!(M); }

Re: CRTP in D?

2009-08-20 Thread div0
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 John C wrote: > div0 Wrote: >> While we're on the subject, is it possible to mixin in a tuple? >> Doesn't seem like you can... >> >> class C(M...) { >> mixin M; >> } >> >> Doesn't work. > > import std.typetuple; > > class C(M...) { > > mixin Type

Re: CRTP in D?

2009-08-20 Thread Bill Baxter
On Thu, Aug 20, 2009 at 12:15 PM, div0 wrote: > -BEGIN PGP SIGNED MESSAGE- > Hash: SHA1 > > John C wrote: >> div0 Wrote: >>> While we're on the subject, is it possible to mixin in a tuple? >>> Doesn't seem like you can... >>> >>> class C(M...) { >>>  mixin M; >>> } >>> >>> Doesn't work. >>

Re: CRTP in D?

2009-08-20 Thread div0
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Bill Baxter wrote: > On Thu, Aug 20, 2009 at 12:15 PM, div0 wrote: >> -BEGIN PGP SIGNED MESSAGE- >> Hash: SHA1 >> >> John C wrote: >>> div0 Wrote: While we're on the subject, is it possible to mixin in a tuple? Doesn't seem like you c