Le 11/12/2011 00:35, kenji hara a écrit :
is(X == function) checks whether the X is a function type.
For example, this code can compile without error.

static assert(is(typeof(doNothing) == function));

doNothing is non-property free function, so its type is function type.


Well, this is true. But this isn't usable due to the autoevaluation, see first case.

I agree that is(X == function) is bit difficult to understand, but it
is consistent feature and there is no bug.

Kenji Hara

This is not a problem of understanding. This is a problem of consistency, and usefullness.

When you look at the types given, the only one that could be true using is(X == function) is one where the function keyword does not appears (int() ). All types using the keyword function will evaluate this expression to false. This inconsistency (1).

Plus, objects of this type cannot be passed around because it realize a function call and pass the result.

Expect in some very hacky way, you cannot ends up with is(X == function) evaluating to true.

Plus, when you look at the behaviour of delegate, this is clearly inconsistent. This is inconsistency (2).

In addition, this is error prone. As matter of facts, experienced programmer did make a mistake with that, without even noticing it !

To me, if it is specified that way, ok, this isn't a compiler bug. In this case, this is a specification bug.

Reply via email to