Why is array.reverse a property and not a method?
Andrei Alexandrescu
SeeWebsiteForEmail at erdani.org
Tue Jul 13 08:09:23 PDT 2010
On 07/13/2010 06:23 AM, Steven Schveighoffer wrote:
> On Mon, 12 Jul 2010 15:42:49 -0400, Andrei Alexandrescu
> <SeeWebsiteForEmail at erdani.org> wrote:
>
>>
>> put(R, E) -> putNext(R, E)
>>
>> Rationale: conveys the notion that there is progress in the output.
>
> Can we have E getNext(R) also for completeness :) Then an input range
> can be defined similarly to an output range (where delegates and ranges
> that support E get() work).
Yah, see the parallel thread.
> Since put/putNext already establishes the notion of throwing when full,
> having getNext throwing when empty would be OK, no?
That does go against the "don't use exceptions for normal control flow"
mantra, with which I agree. From a practical perspective, it makes
client code unnecessarily verbose:
try
{
for (;;) { item = getNext(r); ... }
}
catch (RangeEnd e)
{
}
Andrei
More information about the Digitalmars-d
mailing list