function is not function

Ali Çehreli acehreli at yahoo.com
Fri Sep 21 13:10:53 PDT 2012


On 09/21/2012 12:59 PM, Ellery Newcomer wrote:
> solution is to use std.traits, but can someone explain this to me?
>
> import std.stdio;
>
> void main() {
> auto a = {
> writeln("hi");
> };
> pragma(msg, typeof(a)); // void function()
> pragma(msg, is(typeof(a) == delegate)); // nope!
> pragma(msg, is(typeof(a) == function)); // nope!
> }

You have probably tried the following already:

     pragma(msg, is(typeof(a) == void function()));

Regardless, I think it is a bug because the documentation says that the 
'function' keyword alone should work:

   http://dlang.org/expression.html#IsExpression

<quote>
is ( Type == TypeSpecialization )
The condition is satisfied if Type is semantically correct and is the 
same type as TypeSpecialization.

If TypeSpecialization is one of struct union class interface enum 
function delegate const immutable shared then the condition is satisifed 
if Type is one of those.
</quote>

Ali


More information about the Digitalmars-d-learn mailing list