Pointers to functions (!= "function pointers") should be disallowed entirely

Timon Gehr timon.gehr at gmx.ch
Sat Jun 16 19:24:22 PDT 2012


On 06/17/2012 02:55 AM, Mehrdad wrote:
> I think pointers to functions should be disallowed (and more
> indirections thereof):
>
> typeof(Object.toString)* p;
>

pointers to functions == function pointers.
They are just alternate syntax.

> They can never point anywhere reasonable other than null.

void main(){
     typeof(main)* ptr = &main;
     static assert(is(typeof(ptr)==void function()));
     assert(ptr !is null);
}


More information about the Digitalmars-d mailing list