On Friday, 24 August 2018 at 22:42:19 UTC, Walter Bright wrote:
On 8/24/2018 12:42 PM, tide wrote:
Some problems require new features like how taking the address of a member function without an object returns a function pointer, but requires a delegate where C++ has member function pointers, D just has broken unusable code. Or old features that were implemented poorly (C++ mangling for example).

How to do member function pointers in D:

https://www.digitalmars.com/articles/b68.html

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.

Reply via email to