What's the story with @property again?
Paul Backus
snarwin at gmail.com
Wed Nov 13 16:57:26 UTC 2024
On Wednesday, 13 November 2024 at 16:44:53 UTC, Nick Treleaven
wrote:
> On Sunday, 10 November 2024 at 19:10:48 UTC, Steven
> Schveighoffer wrote:
>> one thing that SDC has implemented is enforcement of
>> `@property` syntax. That is, if a function is labeled
>> `@property`, then `&obj.member` gives you an address to the
>> return of the property, and `obj.member()` would not be valid
>> unless the return value was a callable.
>
> Does it also disallow `writeln = "hi";`? That should be made an
> error IMO.
> https://issues.dlang.org/show_bug.cgi?id=17474
The fact that this works is actually kinda useful for writing
`opDispatch` wrappers. You can write something like
auto opDispatch(string name, Args...)(Args args)
{
return __traits(getMember, payload, name) = args;
}
...and it will work for both member functions and member
variables.
More information about the Digitalmars-d
mailing list