[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: C++

From: Jonathan S. Shapiro
Subject: Re: C++
Date: Mon, 9 Nov 2009 07:56:02 -0800

On Mon, Nov 9, 2009 at 3:56 AM, William Leslie
<address@hidden> wrote:
> The
> problem is that the template has to be /included/ in any using code.
> This means that two compilation units that use minimum<int> will each
> have their own instance of it.

This is an artifact of stale linker technology. It it true in most
current implementations, but it is not *essentially* true, and some
compilation systems (including, I was surprised to find, Microsoft's)
can mitigate this using things like link-time code generation.

The real reason ML can routinely do better on this is that all types
in ML are reference types. I don't think that you want to pay that
extra indirection cost.

We came up with a nice link-time solution (would also work at dynamic
link time) for BitC, but we ran out of time before we could implement

> Worse, because you
> can't put them into a library and have template parameters resolved at
> link time, changes to templates require rebuilding all the code that
> uses them.  It's a very inconvenient way to achieve code reuse IMHO.

This is also true when you add a field to a structure; anything that
changes the signature forces a recompile. It's not a template problem
in particular. But you are right that templates add a new and
unfortunate twist: having no types, it is very hard for the compiler
to analyze the impact of changes to them.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]