RFC on range design for D2

Andrei Alexandrescu SeeWebsiteForEmail at erdani.org
Fri Sep 12 08:40:36 PDT 2008


Sergey Gromov wrote:
> Steven Schveighoffer <schveiguy at yahoo.com> wrote:
>> "Bill Baxter" wrote
>>> I think one thing to consider is what it will take to make a new
>>> container support and "play nice" with the regime proposed.  This
>>> touches on Andrei's point about being hard pressed to think of generic
>>> algorithms to run on an HMM, too.
>>>
>>> The first question is who do you want to "play nice" with?  If you're
>>> going to be writing functions specifically for that container, then
>>> you don't really have to play nice with anyone.  Your container just
>>> needs to have the operations necessary to support those functions.
>> Bill, thanks so much for explaining it like this, I really agree with what 
>> you say.  My concern is that iterator is going to become a 'bad word' and 
>> considered a flawed design.
>>
>> But you are right, there is no need for iterators to be allowed for 
>> std.algorithm, I totally agree with that, I just assumed Andrei meant 
>> iterators would be discouraged for everything, including general use as 
>> pointers into container objects.  If that is not the case, then I 
>> wholeheartedly agree that algorithms should be restricted to ranges, and 
>> iterators should be used only in container operations.
> 
> If you ask me, I think iterators AKA pointers into containers should be 
> discouraged from SafeD.  If you don't care about SafeD you may use 
> whatever you like.  Most library interfaces want to be SafeD to make 
> user's life easier but few care about the library internals as long as 
> they work.

That's also a reason why std.stdio must wrap FILE* into a safe struct. 
Manipulating FILE* objects directly is unsafe even if you disable 
pointer arithmetic.

Andrei


More information about the Digitalmars-d-announce mailing list