What's the story with @property again?

Jonathan M Davis newsgroup.d at jmdavisprog.com
Sat Nov 9 11:58:34 UTC 2024


On Saturday, November 9, 2024 3:36:00 AM MST Anton Pastukhov via Digitalmars-d 
wrote:
> I'm looking here:
> https://forum.dlang.org/post/uhcopuxrlabibmgrbqpe@forum.dlang.org
> and have an impression that @property was on the verge of
> deprecation in 2022. Specs, however, give a warning that this
> feature is "evaluated for its usefulness" but doesn't mention
> deprecation
> (https://dlang.org/spec/function.html#property-functions). So,
> two years later, at the end of 2024, what's the story with
> @property? Is it stuck in limbo?
>
> I also see threads like this
> https://forum.dlang.org/thread/gkvmkiuaaklywvfuyzpz@forum.dlang.org, that
> also end without any resolution. Honestly, this looks sad

I'm pretty sure that it simply hasn't been a priority, and if something more
interesting is going to be done with it, then a DIP will be required (which
some folks have talked about doing, but IIRC, no one has actually written
one yet).

At this point, IIRC, all that @property really does is make it so that
typeof gives the return type of the function and not the type of the
function itself. This is occasionally useful (e.g. std.traits actually uses
it to be able to implement a couple of traits, which would have to be
rethought if it went a away), but for the most part, it's not particularly
valuable, and it does complicate some type introspection, since you have to
deal with the fact that typeof on a function isn't always the type of the
function. For the most part though, it really isn't causing any problems.
Lots of people seem to use it to document that they intend for a function to
be used as a property, so it gets used pretty frequently, but it doesn't
really do much good or bad in practice, so it's largely just documentation.

Honestly, UFCS kind of killed most of what was planned for @property, and no
new plan has ever been decided upon, so it's just sat there, and since it
isn't really causing issues, it hasn't been a priority to figure out what to
do about it. There aren't a lot of people working on the language, and other
stuff has mattered a lot more. In all likelihood, @property will just stick
around as it is until someone takes the time to write a DIP to do something
interesting with it (and it's good enough to be accepted).

- Jonathan M Davis





More information about the Digitalmars-d mailing list