[Issue 3646] Default values of function arguments are ignored when instantiating a template.
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Sat Dec 26 12:51:58 PST 2009
http://d.puremagic.com/issues/show_bug.cgi?id=3646
--- Comment #2 from Eldar Insafutdinov <e.insafutdinov at gmail.com> 2009-12-26 12:51:57 PST ---
(In reply to comment #1)
> This is a bit more tricky than it looks like.
>
> The question here is, how many times should foo be instanciated?
> DMD answers "just 1 time", and I agree with it, since bar and bam have same
> signature and mangling.
> But this only happens if foo!(bar) is instanciated before foo!(bam), because
> when templates are instantiates on first use. When you instanciate foo!(bam)
> first, it doesn't get rewritten and therefore fails to compile.
>
> I guess the only fix for this issue would be to create an implicit trampoline
> to invoke functions with default arguments, but only Walter can say for sure.
Yeah, that was pretty much what I was thinking about. The issue cuts down to a
question, should Foo be instantiated once or are the function types equal? For
binary size and efficiency purposes I agree that there should be one
instantiation. On the other hand for meta programming and code generation which
is what I am doing I would like to have them as separate types, as I don't want
to loose this information. Walter or Andrei would probably have to comment on
this issue.
--
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
More information about the Digitalmars-d-bugs
mailing list