Specialization - Major hole in the spec?

Timon Gehr timon.gehr at gmx.ch
Thu Jan 5 16:47:03 PST 2012


On 01/06/2012 12:22 AM, Peter Alexander wrote:
> On 5/01/12 9:37 PM, Trass3r wrote:
>> On Thursday, 5 January 2012 at 15:11:13 UTC, Timon Gehr wrote:
>>> On 01/05/2012 10:14 AM, Peter Alexander wrote:
>>>> In any case, it is surely a bug. I have *explicitly* specified that T
>>>> must be int, yet it has called a version with T == float.
>>>
>>> No it has called a version with T : float. ":" means "implicitly
>>> converts to". This is by design.
>>
>> I think we should rename this to something like 'type constraint'
>> instead of specialization (and add the explanation that it means
>> implicitly converts). As this thread shows C++ programmers will be
>> confused otherwise.
>
> Upon further investigation, the website disagrees with what you've said.
>
> http://dlang.org/templates-revisited.html
>

Interesting. I think this is an error in the website. Walter?

>
> On the T:int line it says "T must be int type", not "T must implicitly
> convert to int".
>
> Where did you read that : means implicitly converts to? I can't find it
> anywhere on the site, or in TDPL.

It is what it means in 'is' expressions, and what it means in DMD.


More information about the Digitalmars-d mailing list