Are properties mature enough?

Jonathan M Davis newsgroup.d at jmdavisprog.com
Tue Aug 21 21:40:22 UTC 2018


On Tuesday, August 21, 2018 1:46:31 PM MDT Jim Balter via Digitalmars-d-
learn wrote:
> That's a lot of detail. The bottom line is that the warning in
> the spec is completely wrong and should be removed -- using
> property functions is not discouraged, nor is @property.
> @property should be used, both as documentation and because it
> makes typeof work correctly. Maybe it will do even more later.

Whether it makes typeof work correctly is a matter of debate. It makes it
act more like a varable, which is in line with the property function acting
like a variable. However, it isn't actually a variable, and aside from
calling the function without parens or being able to assign to it, it really
doesn't act like a variable. So, having typeof claim that it is actually
tends to cause problems when doing metaprogramming. Also, because @property
isn't required to get the property syntax, what typeof says really doesn't
have much to do with what's syntactically valid. What usually makes more
sense is to check the type of expressions using the symbol rather than
directly checking the type of the symbol. So, while @property serves as a
good way to indicate the intent of the API author, all it really does beyond
that is cause problems with metaprogramming. So, while I definitely use it,
I'd honestly argue that the fact that typeof lies about what the actual type
is when @property is used is a serious problem.

- Jonathan M Davis





More information about the Digitalmars-d-learn mailing list