| Thread overview | |||||
|---|---|---|---|---|---|
|
June 17, 2012 Pointers to functions (!= "function pointers") should be disallowed entirely | ||||
|---|---|---|---|---|
| ||||
I think pointers to functions should be disallowed (and more indirections thereof): typeof(Object.toString)* p; They can never point anywhere reasonable other than null. | ||||
June 17, 2012 Re: Pointers to functions (!= "function pointers") should be disallowed entirely | ||||
|---|---|---|---|---|
| ||||
Posted in reply to Mehrdad | 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); } | |||
June 17, 2012 Re: Pointers to functions (!= "function pointers") should be disallowed entirely | ||||
|---|---|---|---|---|
| ||||
Posted in reply to Timon Gehr | On Sunday, 17 June 2012 at 02:24:23 UTC, Timon Gehr wrote:
> 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);
> }
Ah what!
I guess what confused me was that &Object.toString was a function, which made me think they were "unbound delegates", and hence we couldn't actually set them...
thanks!
| |||
Copyright © 1999-2021 by the D Language Foundation
Permalink
Reply