digitalmars.D - Why type specialization is defined differently than is expression
- deadalnix (3/3) Jun 27 2012 All is in the title.
- Timon Gehr (2/5) Jun 27 2012 You cannot do is(T : class).
- =?ISO-8859-1?Q?Alex_R=F8nne_Petersen?= (13/19) Jun 27 2012 I think what's really worrying is that this is legal:
- Timon Gehr (2/18) Jun 27 2012
- Roman D. Boiko (6/7) Jun 27 2012 Template type specialization must have a basic type after colon.
- Roman D. Boiko (8/15) Jun 27 2012 Why? According to grammar,
- Roman D. Boiko (3/19) Jun 27 2012 Sorry, I read like typeof(T):
- Steven Schveighoffer (6/29) Jun 27 2012 The condition is satisfied if Type is semantically correct and it is the...
- Roman D. Boiko (8/15) Jun 27 2012 No, unless the D specification is outdated.
- Roman D. Boiko (4/20) Jun 27 2012 Ups... Seems I implemented this incorrectly. Indeed, below there
- Steven Schveighoffer (6/21) Jun 27 2012 It's poorly written, TypeSpecialization is restricted for the : case.
- Roman D. Boiko (8/14) Jun 27 2012 Yeah, I found that after your post. Probably it was easier to
- Steven Schveighoffer (5/20) Jun 27 2012 Hm... come to think of it, shouldn't TypeSpecialization be Type instead?
- Roman D. Boiko (6/12) Jun 27 2012 That's what I was trying to explain. It is probably easier to
- deadalnix (3/26) Jun 27 2012 OK, I had misunderstood here too.
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 ?
Jun 27 2012
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).
Jun 27 2012
On 27-06-2012 19:13, Timon Gehr wrote:On 06/27/2012 03:56 PM, deadalnix wrote: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.orgAll 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).
Jun 27 2012
On 06/27/2012 08:21 PM, Alex Rønne Petersen wrote:On 27-06-2012 19:13, Timon Gehr wrote:This is not legal.On 06/27/2012 03:56 PM, deadalnix wrote:I think what's really worrying is that this is legal: void foo(T : class)() { }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).But this is not: template Foo(T : class) { }
Jun 27 2012
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.
Jun 27 2012
On Wednesday, 27 June 2012 at 17:13:10 UTC, Timon Gehr wrote:On 06/27/2012 03:56 PM, deadalnix wrote:Why? According to grammar, IsExpression: is ( Type : TypeSpecialization ) and TypeSpecialization: Type struct union class interface enum function delegate super const immutable inout shared returnAll 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).
Jun 27 2012
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:Sorry, I read like typeof(T): is(typeof(T):class)On 06/27/2012 03:56 PM, deadalnix wrote:Why? According to grammar, IsExpression: is ( Type : TypeSpecialization ) and TypeSpecialization: Type struct union class interface enum function delegate super const immutable inout shared returnAll 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).
Jun 27 2012
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:The condition is satisfied if Type is semantically correct and it is the same as or can be implicitly converted to TypeSpecialization.On Wednesday, 27 June 2012 at 17:13:10 UTC, Timon Gehr wrote:On 06/27/2012 03:56 PM, deadalnix wrote:Why? According to grammar, IsExpression: is ( Type : TypeSpecialization ) andAll 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).Emphasis added.TypeSpecialization is only allowed to be a Type.<<<This is only valid for is( Type == TypeSpecialization) -SteveTypeSpecialization: Type struct union class interface enum function delegate super const immutable inout shared return
Jun 27 2012
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:No, unless the D specification is outdated. IsExpression: is ( Type ) is ( Type : TypeSpecialization ) is ( Type == TypeSpecialization ) ...This is only valid for is( Type == TypeSpecialization)TypeSpecialization: Type struct union class interface enum function delegate super const immutable inout shared return
Jun 27 2012
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:Ups... Seems I implemented this incorrectly. Indeed, below there is a note: TypeSpecialization is only allowed to be a Type.On Wed, 27 Jun 2012 16:16:53 -0400, Roman D. Boiko <rb d-coding.com> wrote:No, unless the D specification is outdated. IsExpression: is ( Type ) is ( Type : TypeSpecialization ) is ( Type == TypeSpecialization ) ...This is only valid for is( Type == TypeSpecialization)TypeSpecialization: Type struct union class interface enum function delegate super const immutable inout shared return
Jun 27 2012
On Wed, 27 Jun 2012 16:32:33 -0400, Roman D. Boiko <rb d-coding.com> wrote:On Wednesday, 27 June 2012 at 20:27:39 UTC, Steven Schveighoffer wrote:It's poorly written, TypeSpecialization is restricted for the : case. Maybe it passes the parser, but fails on semantic. "TypeSpecialization is only allowed to be a Type." -- context for is(Type : TypeSpecialization) -SteveOn Wed, 27 Jun 2012 16:16:53 -0400, Roman D. Boiko <rb d-coding.com> wrote:No, unless the D specification is outdated. IsExpression: is ( Type ) is ( Type : TypeSpecialization ) is ( Type == TypeSpecialization ) ...This is only valid for is( Type == TypeSpecialization)TypeSpecialization: Type struct union class interface enum function delegate super const immutable inout shared return
Jun 27 2012
On Wednesday, 27 June 2012 at 20:35:47 UTC, Steven Schveighoffer wrote:On Wed, 27 Jun 2012 16:32:33 -0400, Roman D. Boiko <rb d-coding.com> wrote: It's poorly written, TypeSpecialization is restricted for the : case. Maybe it passes the parser, but fails on semantic. "TypeSpecialization is only allowed to be a Type." -- context for is(Type : TypeSpecialization)Yeah, I found that after your post. Probably it was easier to implement an IsExpression in a unified way and check semantics separately. Otherwise it would be that IsExpression have to contain different types of members, if Type (not TypeSpecialization) in the `:` case, and the latter in the `TypeSpecialization` case.
Jun 27 2012
On Wed, 27 Jun 2012 16:40:47 -0400, Roman D. Boiko <rb d-coding.com> wrote:On Wednesday, 27 June 2012 at 20:35:47 UTC, Steven Schveighoffer wrote:Hm... come to think of it, shouldn't TypeSpecialization be Type instead? Seems weird to say Type : TypeSpecialization, and then say "TypeSpecialization is only allowed to be Type". Why not Type : Type? -SteveOn Wed, 27 Jun 2012 16:32:33 -0400, Roman D. Boiko <rb d-coding.com> wrote: It's poorly written, TypeSpecialization is restricted for the : case. Maybe it passes the parser, but fails on semantic. "TypeSpecialization is only allowed to be a Type." -- context for is(Type : TypeSpecialization)Yeah, I found that after your post. Probably it was easier to implement an IsExpression in a unified way and check semantics separately. Otherwise it would be that IsExpression have to contain different types of members, if Type (not TypeSpecialization) in the `:` case, and the latter in the `TypeSpecialization` case.
Jun 27 2012
On Wednesday, 27 June 2012 at 20:42:39 UTC, Steven Schveighoffer wrote:Hm... come to think of it, shouldn't TypeSpecialization be Type instead? Seems weird to say Type : TypeSpecialization, and then say "TypeSpecialization is only allowed to be Type". Why not Type : Type?That's what I was trying to explain. It is probably easier to implement an IsExpression this way, because it would always contain members of the same types. Also, I made a typo, should be:and TypeSpecialization in the `==` case.
Jun 27 2012
Le 27/06/2012 22:35, Steven Schveighoffer a écrit :On Wed, 27 Jun 2012 16:32:33 -0400, Roman D. Boiko <rb d-coding.com> wrote:OK, I had misunderstood here too. This whole is stuff is kind of messed up.On Wednesday, 27 June 2012 at 20:27:39 UTC, Steven Schveighoffer wrote:It's poorly written, TypeSpecialization is restricted for the : case. Maybe it passes the parser, but fails on semantic. "TypeSpecialization is only allowed to be a Type." -- context for is(Type : TypeSpecialization) -SteveOn Wed, 27 Jun 2012 16:16:53 -0400, Roman D. Boiko <rb d-coding.com> wrote:No, unless the D specification is outdated. IsExpression: is ( Type ) is ( Type : TypeSpecialization ) is ( Type == TypeSpecialization ) ...This is only valid for is( Type == TypeSpecialization)TypeSpecialization: Type struct union class interface enum function delegate super const immutable inout shared return
Jun 27 2012