What's the story with @property again?

Jonathan M Davis newsgroup.d at jmdavisprog.com
Mon Nov 11 03:25:41 UTC 2024


On Sunday, November 10, 2024 12:10:48 PM MST Steven Schveighoffer via 
Digitalmars-d wrote:
> So I just want to say as a side note, I've been using SDC to
> develop the new GC, and while there are a lot of missing
> features, 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.
>
> I have to say, I quite like this, and I wish D would adopt a more
> strict version of `@property`.
>
> I honestly think we should try a preview switch here...

I'd love to have a more strict version of @property where you're forced to
use it like a property, and parens on it are always used on the return
value. That would be a lot more useful (particularly since delegates and
callables really can't be used with @property functions right now). That's
essentially where we were supposedly going before, but previously, it would
have included the requirement to use parens on non- at property functions, and
UFCS definitely killed that, because people loved dropping the parens with
UFCS. But if we could at least get the enforcement on @property functions so
that they act like actual properties, that would be great.

- Jonathan M Davis





More information about the Digitalmars-d mailing list