Make `& Class.foo` illegal
JN
666total at wp.pl
Thu Aug 27 20:48:01 UTC 2020
On Thursday, 27 August 2020 at 11:20:17 UTC, Johan wrote:
> Currently this code is not rejected by the compiler and instead
> creates non-functioning (undefined) code:
> ```
> struct S {
> void foo() {}
> }
>
> void main() {
> auto a = &S.foo;
> }
> ```
>
> See https://issues.dlang.org/show_bug.cgi?id=21195 .
>
> Considering https://www.digitalmars.com/articles/b68.html, why
> not simply reject `&S.foo` during semantic analysis?
>
> -Johan
What if you want to pass a static member function to a C function
as callback, wouldn't &S.foo be a valid syntax? Something like:
class Mouse
{
extern "C" static void handleClick(int x, int y) { ... }
}
osAbstractionLibrary.setMouseClickHandler(&Mouse.handleClick)?
More information about the Digitalmars-d
mailing list