@property on free function for UFCS?
Adam D. Ruppe via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Sun Jun 14 06:27:05 PDT 2015
On Sunday, 14 June 2015 at 12:53:43 UTC, rcorre wrote:
> Is there a good reference for the current state of @property?
Easy: it does absolutely nothing right now.
> I'm just never sure when I should be using it (if at all).
You should really only use it when you know the function is
semantically the same as a field, aka if you want the @property
function to be entirely invisible.
Don't ask if you want it callable without parens, likely ALL
functions will remain that way, instead ask if you want it to be
entirely substitutable for the return value.
I'd say in practice, only use it when you're returning a callable
and want a.foo() to call the return value (so the fact that foo
is actually a function is entirely hidden) or if you're returning
a ref and want &a.foo to give the address of the referenced
variable instead of a delegate to the function (again, the fact
that it is a function is entirely hidden, it acts identically to
the variable).
Though note that even now, since @property doesn't do anything
yet, you'd still have to call it explicitly, which will mean
compile errors when it is finally implemented...
So perhaps best is to just not use it at all.
More information about the Digitalmars-d-learn
mailing list