D's "accessors" are like abusing operator overloads
Nick Sabalausky
a at a.a
Fri Mar 27 11:02:48 PDT 2009
"BCS" <none at anon.com> wrote in message
news:a6268ff401a8cb7cd0afe22784 at news.digitalmars.com...
>>
>> ts.fromSeconds = 30; // WTF is that supposed to mean?!? But it
>> compiles anyway!
>>
>
> One option would be to only allow that fn = v syntax where fn returns
> void.
>
That still doesn't plug all the holes. Just because a function takes one
argument and returns void still doesn't necessarily imply that it does
something that could be reasonably considered "setting".
---------
Stdout.formatln = "Hello"; // Still doesn't make much sense
---------
class Foo
{
// Complex set of private data members here
void MutateFooInPlace(bool optionA)
{
// Do some sort of fancy in-place mutation of Foo
// "optionA" is some sort of algorithm-adjusting option.
}
}
auto f = new Foo();
f. MutateFooInPlace = false; // Even worse!
---------
More information about the Digitalmars-d
mailing list