Dynamic arrays in D 1.0

Edward Diener eddielee_no_spam_here at tropicsoft.com
Mon May 12 20:59:02 PDT 2008


Sean Kelly wrote:
> Edward Diener wrote:
>>
>> Since dynamic arrays are part of the language and not a separate 
>> library I would have expected built-in functionality to manipulate 
>> them easily. Of course it can be in a library, but it seems even a 
>> general purpose dynamic array library does not exist for D 1.0, so 
>> that seems odd to me.
> 
> What would you suggest adding to tango.core.Array?  I assume insert and 
> remove at some position... perhaps others as well?

Actually once I realized that slicing and concatenation can do what is 
necessary to emulate 'remove', 'insert', and 'replace' fairly easily I 
understood that D covers array manipulation based on indices pretty 
well. Your tango.core.array emulates C++ algorithms on containers pretty 
nicely so I have nothing particular to suggest there since I have not 
tried it out enough. You just might want to take a look at the C++ 
container algorithms, if you have not already done so, to see if there 
is anything there you may have left out which you feel might be 
worthwhile doing in tango.core.Array. But I have no real criticism or 
suggestion for your module.

The only real problem with the slicing/concatenation model may be 
optimization. That may be a reason to still pursue the C++ model of 
dynamic array, aka std::vector, manipulations in Tango.core.array. But I 
have little objection if the design is clear, even if the code is not 
highly optimized.



More information about the Digitalmars-d mailing list