On Thu, 6 May 2010 12:16:22 +0200
Graeme Geldenhuys <graemeg.li...@gmail.com> wrote:

> 2010/5/6 spir ☣ <denis.s...@gmail.com>:
> >
> > If the answers to last 2 questions is "only every 29th of februar", how can 
> > one have a "flexible" array? Is there something like that in stock? Would 
> > you implement it on top of dynamic array, or rather from scratch on top of 
> > static array (since the "dynamicity" does not seem very helpful)?
> >
> 
> Use a list class instead. Descend from TList or embed TList in a class
> as a field variable. I hardly ever use arrays, simply because list
> classes can do everything you mention and works as expected.

Right, Michael gives the same advice. What I need is actually a general-purpose 
sequence type. The point is that insertion/deletion is indeed required, but the 
most common operations are the ones efficient with arrays, esp. plain item 
access via index. This is the reason why sequences in dynamic languages (eg 
python lists) are in fact implemented as flexible arrays, that simply happen to 
also behave like lists from the point of view of client code.
So, if TList is a type of linked list, it can probably not do the job for me. 
Anyway, I'm not a production programmer & would be pleased to explore this 
topic as an occasion to learn Pascal and fp further.
Tips/pointers welcome. (I'm currently stuck with how to have a [pointer] 
variable/field refer to a static array which size may change ;-)

denis
________________________________

vit esse estrany ☣

spir.wikidot.com
_______________________________________________
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal

Reply via email to