On Fri, 16 Sep 2016 08:51:24 +0000, Stefan Koch wrote:
> The answer is to make every template-argument unique.
> Such that it can be uniquely identified with a numeric id.

So the compiler might intern or memoize some things, and if two templates 
take the same interned values as parameters, the cached template 
instantiation will be used. (This will happen with builtin types and 
possibly some literals.)

For instance, this will be a cache hit:

  alias TypeA = Typedef!int;
  alias TypeB = Typedef!int;

On the other hand, in a change of behavior, this will be a cache miss and 
the template is instantiated twice:

  alias myint = int;
  alias TypeA = Typedef!int;
  alias TypeB = Typedef!myint;

And this may or may not be a cache hit:

  alias TypeA = Typedef!(int, 0, "A");
  alias TypeB = Typedef!(int, 0, "A");

If someone tries implementing the recursive form of the Fibonacci 
function with your change in place, they'll have unusably long compile 
times. However, in the typical case, compile times will be faster (and 
specific types can more easily receive special treatment as needed).

Reply via email to