[fpc-pascal] about dynamic array -- p

Thierry Coq tcoq at free.fr
Sat May 8 12:58:35 CEST 2010


Denis,

you need to get up to speed on <types>, since this is one of the 
fundamental (and better) differences of pascal. You'll find the typing 
system actually helps you a lot.

FYI, class is one of the possible types.  Basically in Pascal, some 
types are basic: integer, real, some types are structured: records 
array, some types are objects (coming from TP/BP), some types are 
classes and interfaces. There are also some special types like variants. 
You've also seen the difference between static and dynamic types. Please 
look up the reference manual for that here:
ftp://ftp.freepascal.org/pub/*fpc*/docs-pdf/ref.pdf

About the RTL: you'll find a good manual here:
ftp://ftp.freepascal.org/pub/*fpc*/docs-pdf/rtl.pdf

About TList: it's item type is a untyped pointer, so you can't do 
anything with the results unless you type it first as mentioned. 
TObjectList, TComponentList, etc all derive from TList and provide a 
typed item.

It's a good idea for you, if you need it often, to derive your own 
TIntegerList from TList (or any other container in Cntnrs or elsewhere). 
You'll find many tutorials on the web, where TIntegerList is provided.

With the generics now available in FPC, it's also easy to have a whole 
hierarchy of TGenericLists which could be easily instanciated to 
TIntegerList as needed.

Out of FPC/Lazarus, there are excellent container libraries, that can 
reduce your workload. Most of what you need is already there. Decal is one.

Best regards,
Thierry



spir ☣ wrote:
> On Fri, 7 May 2010 06:10:30 +0200
> cobines <cobines at gmail.com> wrote:
>
>
> PS : I also need the pointer's mediation when a func/proc expects a (typed) element. Must rewrite the code to use an element pointer as parameter (and pass a pointer from the list). This is more annoying since it obscures the func/proc's signature.
>
> Is the source of this issue really that these pointers are untyped? If yes, maybe a way to get rid of such noise would be to subtype TFPList into a list of typed pointers?
>
> (I don't know yet how to use fpc's type system. So new in this domain I have no idea what the difference between type & class may be ;-) But this will come soon, I guess...)
>
> Denis
> ________________________________
>
> vit esse estrany ☣
>
> spir.wikidot.com
> _______________________________________________
> fpc-pascal maillist  -  fpc-pascal at lists.freepascal.org
> http://lists.freepascal.org/mailman/listinfo/fpc-pascal
>
>
>   




More information about the fpc-pascal mailing list