Dicebot on leaving D: It is anarchy driven development in all its glory.

Timon Gehr timon.gehr at gmx.ch
Sat Aug 25 13:32:36 UTC 2018


On 25.08.2018 03:43, Walter Bright wrote:
> On 8/24/2018 4:22 PM, tide wrote:
>> struct SomeStruct
>> {
>>      void foo() {
>>          // use SomeStruct
>>      }
>> }
>>
>>
>> void broken()
>> {
>>      void function() foo = &SomeStruct.foo;
>>      foo(); // runtime error, isn't actually safe uses wrong calling 
>> convention as well
>> }
>>
>> Not really lack of feature so much as there exists broken code. This 
>> has been valid code for god knows how long. At some point it was 
>> usable in @safe, but it looks you can't take an address of a member 
>> function without "this" as well in safe anymore.
> 
> 
> That's because it isn't safe. But being able to take the address is 
> important for system work.

So is taking the address of an `int` variable. The analogous point is 
that the type of `&x` for `x` an `int` should be `int*` (and not e.g. 
`string*`). D gets this right, and it should be equally obvious that it 
should get it right for the member function pointer case. (Or at least, 
not wrong. Using e.g. `void*` instead of an incompatible type would 
already be an improvement.)


More information about the Digitalmars-d mailing list