Revised RFC on range design for D2
Andrei Alexandrescu
SeeWebsiteForEmail at erdani.org
Fri Sep 26 09:23:55 PDT 2008
KennyTM~ wrote:
> Andrei Alexandrescu wrote:
>> KennyTM~ wrote:
>>> Andrei Alexandrescu wrote:
>>>> Bruno Medeiros wrote:
>>>>> As a matter of coding style conventions, I would say that using the
>>>>> implicit property function call feature on a function that changes
>>>>> state is *bad* style, and surely hope the community would agree on
>>>>> that.
>>>>
>>>> I sure hope they won't agree to an unsupported assertion.
>>>>
>>>
>>> Actually I *do* hate this "feature" ^_^.
>>>
>>> And this "feature" has been put to challenged before:
>>> * Bug 2159. (http://d.puremagic.com/issues/show_bug.cgi?id=2159)
>>> * "Omitting Parens is an Evil"
>>> (http://www.digitalmars.com/d/archives/digitalmars/D/Omittable_parens_is_an_evil_73881.html)
>>>
>>> *http://www.digitalmars.com/pnews/read.php?server=news.digitalmars.com&group=D&artnum=17579
>>>
>>> But nothing got changed.
>>
>> I don't think the bug report has much strength.
>
> I mean the discussion within the bug report. That's a voice from the
> community isn't it?!
I agree. But then should we take arguments at face value, or just
consider them valid because they exist?
>>> To the very least, when using next as a property I assume the call
>>> won't produce any secondary effect on src from the syntax, since I'm
>>> just reading a state! Not so if one calls src.next() as the "()" is
>>> an alarming sign that src _may_ change afterwards. This could is just
>>> a problem of personal taste since the compiler does not forbid
>>> src.next(), but not so if you're reading other's code.
>>>
>>> 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".
>>
>
> It's fine not to use ++src since C++ is the only language that uses this
> syntax for iterators anyway, but may I mention that, to increase all
> elements of an array you use ++a[], note that there is a [] in the end.
> ++a is syntax error anyway.
>
> Also you should complain about ++p vs ++*p for a pointer p ;)
>
> Like the () after the function call, which says I want to return the
> value after the function execution instead of the function object, the
> [] to my mind also signify I'm working on the content of the array, not
> the array itself.
I agree, hence my "far-fetched" qualification in the reply to Steve.
Andrei
More information about the Digitalmars-d-announce
mailing list