D's "accessors" are like abusing operator overloads
Michel Fortin
michel.fortin at michelf.com
Fri Mar 27 17:43:20 PDT 2009
On 2009-03-27 04:45:26 -0400, "Simen Kjaeraas" <simen.kjaras at gmail.com> said:
> I feel the problem here is that you can access a type's static members
> through an instance of it, not so much the property syntax.
>
> One could argue that auto foo = TimeSpan.seconds = 30; looks weird, but
> writing weird code is in no way dependent on property syntax.
Perhaps static being accessible from the instance is a problem, but you
can easily work around the problem by making the function's name
clearer by adding a verb. If you had:
auto foo = TimeSpan.createFromSeconds = 30;
it'd still look strange, sure, but the intent would still be pretty
clear. So in short functions that perform an action should have a verb.
--
Michel Fortin
michel.fortin at michelf.com
http://michelf.com/
More information about the Digitalmars-d
mailing list