range and algorithm-related stuff

Andrei Alexandrescu SeeWebsiteForEmail at erdani.org
Sun Jan 25 07:17:45 PST 2009


Sergey Gromov wrote:
> Sat, 24 Jan 2009 17:09:07 -0800, Andrei Alexandrescu wrote:
> 
>> I'm working on the new range stuff and the range-based algorithm. In all 
>> likelihood, you all might be pleased with the results.
>>
>> I wanted to gauge opinions on a couple of issues. One is, should the 
>> empty() member function for ranges be const? On the face of it it 
>> should, but I don't want that to be a hindrance. I presume non-const 
>> empty might be necessary sometimes, e.g. figuring out if a stream is 
>> empty effectively means fetching an element off it.
> 
> I have a hard time imagining a use for a const range.

Read-only arrays for example.

> They're supposed
> to be structs, right?

Yah.

> Const value argument is not a very useful idiom.

Not in C++ you mean! In D the ballgame is rather different.

> Also you cannot do much with a const range.

If it has random access, it's effectively a read-only array.

> OTOH you never know what downs will invent next time.  Supporting const
> transparency as much as possible seems to be the right solution.

Yah. And (as I also discovered yesterday without joy) ref transparency 
as well...


Andrei



More information about the Digitalmars-d mailing list