What's wrong with D's templates?
yigal chripun
yigal100 at gmail.com
Mon Dec 21 02:25:29 PST 2009
Rainer Deyke Wrote:
> yigal chripun wrote:
> > 2) structural typing (similllar to Go?)
> > tp!(Foo) // OK
> > tp!(Bar) // also OK
> >
> > 3) C++ style templates where the compatibility check is against the
> > *body* of the template.
> >
> > If you think of templates as functions the compiler executes, the
> > difference between the last two options is that option 2 is staticly
> > typed vs. option 3 which is dynamicaly typed. We all use D because we
> > like static typing and there's no reasone to not extend this to
> > compile-time as well.
>
> I prefer to think of option 2 as explicitly typed while option 3 uses
> type inference. Type inference is a good thing.
>
>
>
> --
> Rainer Deyke - rainerd at eldwood.com
You might prefer that but it's incorrect. This is exactly equivalent to calling a Ruby function vs. a D function, only happens at the compiler's run-time instead your app's run-time.
Errors that the compiler statically checks in D will only be caught at run-time in Ruby. In our case, this means that a user of a tempate can get compilation errors for the temple code itself.
More information about the Digitalmars-d
mailing list