Make `& Class.foo` illegal
Johan
j at j.nl
Fri Aug 28 01:44:19 UTC 2020
On Friday, 28 August 2020 at 01:26:58 UTC, Avrina wrote:
> On Friday, 28 August 2020 at 00:25:15 UTC, sarn wrote:
>>
>> None of that says anything about syntax, but it's why D
>> doesn't have member function pointers, per se, like C++ does.
>
> D does technically have them. They just aren't type safe. As
> other people have said, the type should be either void*, or a
> delegate with a null data pointer.
I much prefer if people refrain from making bold statements that
are not facts. D does not "technically" have member function
pointers. Please don't confuse what is happening in assembly for
some architecture with what the language guarantees. There is no
guarantee that a delegate call is the same as a method call with
implicit `this` parameter.
`&Struct.foo` currently has no meaning for non-static member
function foo, so let's agree on fixing the compiler to error on
it. If you want `&Struct.foo` to have a meaning, e.g. member
function pointers, please write a DIP.
(sorry for the agitated email, I'm trying to make some progress
here, instead of endless debate about something off-topic)
-Johan
More information about the Digitalmars-d
mailing list