Template argument deduction and default args

Manu via Digitalmars-d digitalmars-d at puremagic.com
Thu Jul 24 08:21:54 PDT 2014


On 24 July 2014 22:03, John Colvin via Digitalmars-d <
digitalmars-d at puremagic.com> wrote:

> On Thursday, 24 July 2014 at 11:39:13 UTC, Manu via Digitalmars-d wrote:

Although... the more I think about it, the more I wonder why it matters if
>> the syntax is ambiguous when the name is taken in isolation, that never
>> actually happens...
>> Why can't it just mean 'either the template, or the default arg
>> instantiation', and be resolved when it's actually used?
>> Is it possible for templates or types to both appear in the same context
>> and create an actual ambiguity? What would that expression look like?
>> The only place I can imagine a conflict could occur would be within an
>> is()
>> expression, but I'm not sure... can a uninstantiated template be used in
>> an
>> is() expression where a type would also be a meaningful fit?
>>
>> Generally, templates do this:
>>   T!()
>> And types do this:
>>   T var;
>>
>> It's clear syntactically from 'T!()' that T is not a default args
>> instantiation of T, because it's involved in a template instantiation
>> expression.
>> It's also clear from 'T var' that T is not a template, because a variable
>> needs to have a type.
>>
>
> Seeing as templates can resolve to other templates, mixin templates,
> values, functions and types, the situation is complicated.
>

This is just FUD without any case for consideration.
All of those different resolutions imply different syntactic contexts. I'm
still not sure of a case where a genuine ambiguity arises.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puremagic.com/pipermail/digitalmars-d/attachments/20140725/bf65c220/attachment.html>


More information about the Digitalmars-d mailing list