View mode: basic / threaded / horizontal-split · Log in · Help
June 27, 2012
Why type specialization is defined differently than is expression type specialization ?
All is in the title.

I can do is(T : class) but not template(T : class) . Is this intended or 
is it because it is ?
June 27, 2012
Re: Why type specialization is defined differently than is expression type specialization ?
On 06/27/2012 03:56 PM, deadalnix wrote:
> All is in the title.
>
> I can do is(T : class) but not template(T : class) . Is this intended or
> is it because it is ?

You cannot do is(T : class).
June 27, 2012
Re: Why type specialization is defined differently than is expression type specialization ?
On 27-06-2012 19:13, Timon Gehr wrote:
> On 06/27/2012 03:56 PM, deadalnix wrote:
>> All is in the title.
>>
>> I can do is(T : class) but not template(T : class) . Is this intended or
>> is it because it is ?
>
> You cannot do is(T : class).

I think what's really worrying is that this is legal:

void foo(T : class)()
{
}

But this is not:

template Foo(T : class)
{
}

-- 
Alex Rønne Petersen
alex@lycus.org
http://lycus.org
June 27, 2012
Re: Why type specialization is defined differently than is expression type specialization ?
On 06/27/2012 08:21 PM, Alex Rønne Petersen wrote:
> On 27-06-2012 19:13, Timon Gehr wrote:
>> On 06/27/2012 03:56 PM, deadalnix wrote:
>>> All is in the title.
>>>
>>> I can do is(T : class) but not template(T : class) . Is this intended or
>>> is it because it is ?
>>
>> You cannot do is(T : class).
>
> I think what's really worrying is that this is legal:
>
> void foo(T : class)()
> {
> }
>

This is not legal.

> But this is not:
>
> template Foo(T : class)
> {
> }
>
June 27, 2012
Re: Why type specialization is defined differently than is expression type specialization ?
On Wednesday, 27 June 2012 at 19:23:07 UTC, Timon Gehr wrote:
> This is not legal.

Template type specialization must have a basic type after colon.

s/class/Object

should make it legal. By the way, it is not possible to 
specialize for structs this way, is it? I mean, via template type 
specialization, not via template constraints.
June 27, 2012
Re: Why type specialization is defined differently than is expression type specialization ?
On Wednesday, 27 June 2012 at 17:13:10 UTC, Timon Gehr wrote:
> On 06/27/2012 03:56 PM, deadalnix wrote:
>> All is in the title.
>>
>> I can do is(T : class) but not template(T : class) . Is this 
>> intended or
>> is it because it is ?
>
> You cannot do is(T : class).

Why? According to grammar,

IsExpression:
is ( Type : TypeSpecialization )

and

TypeSpecialization:

Type struct union class interface enum function delegate super 
const immutable inout shared return
June 27, 2012
Re: Why type specialization is defined differently than is expression type specialization ?
On Wednesday, 27 June 2012 at 20:15:43 UTC, Roman D. Boiko wrote:
> On Wednesday, 27 June 2012 at 17:13:10 UTC, Timon Gehr wrote:
>> On 06/27/2012 03:56 PM, deadalnix wrote:
>>> All is in the title.
>>>
>>> I can do is(T : class) but not template(T : class) . Is this 
>>> intended or
>>> is it because it is ?
>>
>> You cannot do is(T : class).
>
> Why? According to grammar,
>
> IsExpression:
> is ( Type : TypeSpecialization )
>
> and
>
> TypeSpecialization:
>
> Type struct union class interface enum function delegate super 
> const immutable inout shared return

Sorry, I read like typeof(T):

is(typeof(T):class)
June 27, 2012
Re: Why type specialization is defined differently than is expression type specialization ?
On Wed, 27 Jun 2012 16:16:53 -0400, Roman D. Boiko <rb@d-coding.com> wrote:

> On Wednesday, 27 June 2012 at 20:15:43 UTC, Roman D. Boiko wrote:
>> On Wednesday, 27 June 2012 at 17:13:10 UTC, Timon Gehr wrote:
>>> On 06/27/2012 03:56 PM, deadalnix wrote:
>>>> All is in the title.
>>>>
>>>> I can do is(T : class) but not template(T : class) . Is this intended  
>>>> or
>>>> is it because it is ?
>>>
>>> You cannot do is(T : class).
>>
>> Why? According to grammar,
>>
>> IsExpression:
>> is ( Type : TypeSpecialization )
>>
>> and

The condition is satisfied if Type is semantically correct and it is the  
same as or can be implicitly converted to TypeSpecialization.  
>>>TypeSpecialization is only allowed to be a Type.<<<

Emphasis added.

>>
>> TypeSpecialization:
>>
>> Type struct union class interface enum function delegate super const  
>> immutable inout shared return

This is only valid for is( Type == TypeSpecialization)

-Steve
June 27, 2012
Re: Why type specialization is defined differently than is expression type specialization ?
On Wednesday, 27 June 2012 at 20:27:39 UTC, Steven Schveighoffer 
wrote:
> On Wed, 27 Jun 2012 16:16:53 -0400, Roman D. Boiko 
> <rb@d-coding.com> wrote:
>>> TypeSpecialization:
>>>
>>> Type struct union class interface enum function delegate 
>>> super const immutable inout shared return
>
> This is only valid for is( Type == TypeSpecialization)

No, unless the D specification is outdated.

IsExpression:
is ( Type )
is ( Type : TypeSpecialization )
is ( Type == TypeSpecialization )
...
June 27, 2012
Re: Why type specialization is defined differently than is expression type specialization ?
On Wednesday, 27 June 2012 at 20:32:34 UTC, Roman D. Boiko wrote:
> On Wednesday, 27 June 2012 at 20:27:39 UTC, Steven 
> Schveighoffer wrote:
>> On Wed, 27 Jun 2012 16:16:53 -0400, Roman D. Boiko 
>> <rb@d-coding.com> wrote:
>>>> TypeSpecialization:
>>>>
>>>> Type struct union class interface enum function delegate 
>>>> super const immutable inout shared return
>>
>> This is only valid for is( Type == TypeSpecialization)
>
> No, unless the D specification is outdated.
>
> IsExpression:
> is ( Type )
> is ( Type : TypeSpecialization )
> is ( Type == TypeSpecialization )
> ...

Ups... Seems I implemented this incorrectly. Indeed, below there 
is a note:

TypeSpecialization is only allowed to be a Type.
« First   ‹ Prev
1 2
Top | Discussion index | About this forum | D home