DI File Generation
Jonathan M Davis
jmdavisProg at gmx.com
Wed Dec 14 15:56:48 PST 2011
On Thursday, December 15, 2011 00:26:05 Paulo Pinto wrote:
> Am 14.12.2011 21:13, schrieb Jonathan M Davis:
> >> Also, _all_ templated _anything_ has to be put in the .di file, and a
> >> lot of>
> > stuff tends to be templated in D (especially in the standard library),
> > so it's pretty easy to need to put a large portion of your code in the
> > .di file anyway.
> I think that Modula-3, Eiffel and Ada don't have issues with having
> "template" declaration in the interface part, with the definition being
> done in the implementation part.
>
> Then again, what they support is what is more commonly known as generics.
>
> I imagine you mean that metaprogramming requires the template code to be
> in the .di file as well, right?
As similar as they may appear, templates and generics are completely different.
With templates, you're literally generating code, and the compiler needs to
full source of the template to generate that code. Generics typically means
that you have one set of code which is just used with different types
(typically enabled by the fact that all of the type have a base class which
they share). So, with generics, you can separate interface and implementation,
but that's impossible with templates (C++ has the same issue). The code which
is generated could vary drastically depending on what you try and instantiate
a template with, unlike with generics. And ultimately, what it comes down to
is the fact that templates literally generate code, so their full source is
required.
- Jonathan M Davis
More information about the Digitalmars-d
mailing list