Michiel Helvensteijn wrote:
Nick Sabalausky wrote:
1. Like in C#, you shouldn't need to define paramater lists for "set" and
"get". They're always going to be the same. In the case of "set", it's
always going to be just the one param, and it'll be the new value, so just
make a special predefined var. Something like:
get { return this.len; }
set { this.len = value; } // "value" (like in C#), or "$" or something
like that
I have to disagree. By that logic, we would abolish parameter-names
altogether and access formal parameters by number. set has a parameter, and
the programmer should be able to name it.
It's very different. A setter has a very specific meaning: set some
value. That's why it's called "value". Another name could be the name of
the property ("len") or something like "newLen". Which other name would
you use?
A general function can have any kind of meaning, and so its parameters,
and that's why it's ok to have names for them.
Also, removing the parentheses would be confusing.
That's more a matter of taste. In C# I find this ok.
I believe it might be
better to make them look like this, even:
property int length {
auto get() { .. }
void set(auto name) { .. }
name? But it's the length. :-P