ufcs and integer params
Timon Gehr
timon.gehr at gmx.ch
Sun Jul 15 13:47:41 PDT 2012
On 07/15/2012 09:41 PM, Jonathan M Davis wrote:
> On Sunday, July 15, 2012 11:56:57 Jonathan M Davis wrote:
>>> What is enforced here? Why would it matter if anything is 'enforced'?
>>
>> If you marked it as a property, then it's supposed to be abstracting a
>> variable and should be treated as one, just like if it's a normal function,
>> it should be invoked as a function, just like ++ shouldn't suddenly do --,
>> and / shouldn't *.
>
> And on a purely objective note, if you don't have property enforcement, you
> can't turn a property function into a variable, because even though it's
> supposed to be used as one, you can't guarantee that everyone's using it that
> way, and if they're using it as a function, changing the property into a
> variable will break their code. And part of the point of properties is to be
> able to switch between variables and property functions depending on whether
> additional protections or calculations or whatnot are required for that
> variable/property. Property enforcement is required in order to allow that.
>
> - Jonathan M Davis
No it is not, assuming that property enforcement is supposed to mean
that function 'foo' cannot be called like 'foo' if it is not annotated
@property.
There is no objective argument for banning this, except that the syntax
would be made free for alternative use.
@property means: always implicitly call if it can be called without
arguments. If it cannot, disallow calls that are not of the form fun =
argument; (After the op= operators have been properly rewritten.)
And that is completely sufficient for transparently switching between
variable/property. Stuff that is *not* annotated @property has no
relevance.
More information about the Digitalmars-d-learn
mailing list