Re: How templates might be improved

2016-09-17 Thread Stefan Koch via Digitalmars-d
On Friday, 16 September 2016 at 08:51:24 UTC, Stefan Koch wrote: [...] I just found http://llvm.org/docs/doxygen/html/FoldingSet_8h_source.html, So it looks like the llvm guys are already using the intern-everything approach, It makes sense since in ssa based forms this is pretty easy to

Re: How templates might be improved

2016-09-17 Thread Chris Wright via Digitalmars-d
On Sat, 17 Sep 2016 12:02:47 +, Stefan Koch wrote: > On Friday, 16 September 2016 at 23:44:42 UTC, Chris Wright wrote: > > >> 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 =

Re: How templates might be improved

2016-09-17 Thread Stefan Koch via Digitalmars-d
On Saturday, 17 September 2016 at 12:02:47 UTC, Stefan Koch wrote: On Friday, 16 September 2016 at 23:44:42 UTC, Chris Wright wrote: 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 =

Re: How templates might be improved

2016-09-17 Thread Stefan Koch via Digitalmars-d
On Friday, 16 September 2016 at 23:44:42 UTC, Chris Wright wrote: 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; No It would not be a miss the

Re: How templates might be improved

2016-09-16 Thread Chris Wright via Digitalmars-d
On Fri, 16 Sep 2016 08:51:24 +, 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

Re: How templates might be improved

2016-09-16 Thread Stefan Koch via Digitalmars-d
On Friday, 16 September 2016 at 08:51:24 UTC, Stefan Koch wrote: so big that the search for the saved instance if more expensive that dumb reinstanciation without looking for saved instance would be faster. Supposed to say "So big that search for the saved instance _can be_ as expensive as

How templates might be improved

2016-09-16 Thread Stefan Koch via Digitalmars-d
Hi Guys, I have decided to shed some light upon the plan I have for templates. First let's focous on the problem(s) with them. The main problem is instanciation, here is how it works: When we encounter a TemplateInstance in an expression, We search for the declaration on that template, If