https://issues.dlang.org/show_bug.cgi?id=8161

--- Comment #8 from Jonathan M Davis <issues.dl...@jmdavisprog.com> ---
(In reply to Nick Treleaven from comment #7)
> Updated the title. Please give a reason why dmd shouldn't reject invalid
> @property functions.

The rules for using functions as properties currently have nothing to do with
@property, and it's not clear that @property is even going to stay in the
language. The plans for @property were dropped in that there are zero plans to
enforce it (which includes the removal of -property), and it's not at all clear
what's going to happen to it. It currently does very little, and adding any
kind of enforcement to it at this point when it's not clear what (if anything)
we're going to do with it really doesn't make sense. At this point, Walter and
Andrei need to make a decision on what we're going to do with @property - be
that on their own or as the result of a DIP.

As it stands, @property does almost nothing. Off the top of my head, the list
is:

1. It affects the result of typeof (the result is the type of the return value
if @property is used, whereas it's the type of the function if @property isn't
used).

2. It affects the mangling of the function (including affecting
std.traits.functionAttributes).

3. It's not legal to overload a @property function with a non-@property
function or vice versa.

None of that involves enforcing that @property acts like a property function or
that it is used as one, and none of it involves enforcing anything about
non-@property functions.

When UFCS was introduced, it became _extremely_ popular to leave off parens on
function calls, and that killed any plans to enforce @property. That does not
mean that we couldn't end up with some kind of enforcement that doesn't
restrict what happens with non-@property functions, and maybe some kind of
enforcement could be added to restrict the use of the assignment syntax to
@property setters in order to make stuff like assigning to writeln illegal, but
a DIP is required to sort all of that out, and as I understand it, at this
point, Andrei and Walter consider @property to be a serious misstep. So, it
really doesn't make sense to try and do anything to @property right now unless
that involves writing a DIP with a full plan of what we're going to do with
@property.

--

Reply via email to