Change representation of dynamic arrays?

Chris Miller chris at dprogramming.com
Sat Oct 20 19:57:05 PDT 2007


On Sat, 20 Oct 2007 02:27:29 -0400, Walter Bright  
<newshound1 at digitalmars.com> wrote:

> Chris Miller wrote:
>> I wonder what kind of iterators you have in mind. Why couldn't the  
>> iterators just hold start and end pointers? It would only need to be  
>> calculated when creating an iterator from a non-iterator. Or perhaps  
>> you want a slice to be an iterator itself, so you could just do  
>> slice++ and it slices out the first element.
>
> I think you answered it!

I'm starting to think the change might not be such a good idea. Imagine  
all the existing code extensively using length. This change is for one  
thing, that could probably just as easily be improved by changing how that  
one thing is implemented, without affecting all this other code. It's not  
even really about supporting legacy usage; the other methods are probably  
mostly quite valid still, and iterators won't solve all those cases.

Also, doing slice++ doesn't allow slice-- safely (not that all forward  
iterators are backwards iterators, but an iterator from a slice should be  
bidirectional). Slice iterators should probably have 3 pointers:  
beginning, end, and current position. Just build an iterator from a slice,  
which is a couple extra cycles up front.

I really want to hear more about what's going on, instead of guessing how  
grand things are going to be, or not going to be. How about another  
newsgroup for possible future plans, like digitalmars.D.alpha



More information about the Digitalmars-d mailing list