Revised RFC on range design for D2
Michel Fortin
michel.fortin at michelf.com
Sat Sep 27 05:47:48 PDT 2008
On 2008-09-27 00:01:05 -0400, Christopher Wright <dhasenan at gmail.com> said:
> Steven Schveighoffer wrote:
>> "Andrei Alexandrescu" wrote
>>>> P.S. If src.next() is too lengthy, why not just adopt ++src?
>>> Because people (in wake of the recently introduced array operations)
>>> may legitimately expect that to mean "increment all elements of src".
>>
>> So in one case, you believe people's assumptions aren't important, i.e.
>> an assumption that .next without parens will not change anything on the
>> object, yet in another case you believe people's assumptions are the
>> main argument. This doesn't sound consistent.
>
> What if it were src.advance instead? Since it's a verb, it's easier to
> associate it with an action that might change state rather than simply
> reading the state of src.
Very true.
> For me, I use the no-parentheses version in either of these cases:
> 1. I'm using the function as a property (auto name = field.name).
> 2. The function name is a verb (mocks.replay).
>
> This seems reasonably unambiguous in my personal experience, though it
> helps that I have few locals in most of my methods and use a prefix for
> private members.
Indeed. I think all function names which are not simple getters or
setters should have a verb in their name, especially in D where there
is no syntax difference between a property and a function.
And I like pretty much the feature of not having to put parenthesis for
function calls with no arguments. The only problem I have with it is
that it makes working with delegates a little messier, especially when
dealing with delegate properties which just *can't* behave as normal
variables.
--
Michel Fortin
michel.fortin at michelf.com
http://michelf.com/
More information about the Digitalmars-d-announce
mailing list