What is this strange alias syntax?

Jesse Phillips jessekphillips+D at gmail.com
Fri May 20 21:22:06 PDT 2011


Andrej Mitrovic Wrote:

> Taken from the docs:
> 
> alias int func(int);
> void main()
> {
>     if ( is(func[]) )               // not satisfied because arrays of
>         writeln("satisfied");    // functions are not allowed
>     else
>         writeln("not satisfied");
> }
> 
> It will print not satisfied. But I'm not sure what func is supposed to be? An alias.. to what? I can't declare variables of its type:
>     func x;
>     error:  variable test.main.x cannot be declared to be a function
> 
> Of course if you write the alias the usual way it will print 'satisfied'. Nothing strange about having an array of functions in D:
> 
> alias int function(int) func;
> void main()
> {
>     if ( is(func[]) )
>         writeln("satisfied");
>     else
>         writeln("not satisfied");
> }

Well, I have no idea. File a bug maybe.


More information about the Digitalmars-d-learn mailing list