Do we want functions to act as properties, or merely omit parens for ufcs/chaining?

FG home at fgda.pl
Tue Jan 29 03:36:24 PST 2013


On 2013-01-29 09:03, eles wrote:
> Let me turn the table: why not thinking about the property as a variable that,
> optionally (start another UFCS/opt-parens discussion here...) accept the syntax:
>
> v(2);

It is a bit confusing because if it were methods/functions you'd typically have 
"getV()" and "setV(2)" which show what is being done here. "v(2)" on the other 
hand doesn't make it clear whether it will set the value or read it. After all 
"2" might be some flag/index/anything used to specify the return value and it 
still won't make "v(int)" a setter. In the end one would have to look into the 
docs to see what "v" does. This is unnecessary if you either tell in the 
function name what will be performed or use the property like any normal 
variable. Therefore when using properties I would rather just see "v" and "v = 
2" (and also expect "w = v = 2" to work).

Assuming that "w" is a plain int variable, I wouldn't expect to see v(2) 
anywhere outside initialization, just like I would not expect to see w(2).


More information about the Digitalmars-d mailing list