Make `& Class.foo` illegal
sarn at theartofmachinery.com
Fri Aug 28 00:25:15 UTC 2020
On Thursday, 27 August 2020 at 16:30:03 UTC, H. S. Teoh wrote:
> In C++, there's this construct called a member function
> pointer, which has its own special type and requires the caller
> to specify an object before the function can be called.
> Arguably, that's what D should be implementing.
I don't know if you've seen them before, but these two articles
explain the reasoning behind D not having member function
tl;dr: C++ member function pointers are complicated when you get
into the details, and the sanest implementation is with thunks
that are equivalent to lambdas or delegates. Ironically, the
most common usage of member function pointers turned out to be
building complicated versions of lambdas and closures (at least
before C++ got them built in).
None of that says anything about syntax, but it's why D doesn't
have member function pointers, per se, like C++ does.
More information about the Digitalmars-d