www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - Locally Instantiated Templates

reply Ellery Newcomer <ellery-newcomer utulsa.edu> writes:
Walter alluded to these a while back in one of his Dr Dobbs articles
(nested functions, part 2), and this evening I've been playing with them
a little.

It doesn't look like they be mentioned anywhere in the spec.

How do they work? It looks kinda like you would just replace any
nonlocal symbol 'a' with '.a' and then do the local instantiation part.
Or maybe not.

Does local instantiation just mean the template instance is located in
the stack (heap?) frame, and otherwise is conceptually the same as any
other template instance? e.g. same scoping rules?

Also, the compiler seems to disallow them for non-global templates. How
does that tie in with the rest of it?
Oct 25 2009
parent Kagamin <spam here.lot> writes:
Ellery Newcomer Wrote:

 Does local instantiation just mean the template instance is located in
 the stack (heap?) frame, and otherwise is conceptually the same as any
 other template instance? e.g. same scoping rules?
templates have no storage. Template is just a semantical construct for parameterizing types. Template members (variables, functions, types) may have storage.
Oct 26 2009