[fpc-pascal] Dynamic arrays using management operators

Ryan Joseph ryan at thealchemistguild.com
Mon Jun 4 12:12:08 CEST 2018



> On Jun 4, 2018, at 4:39 PM, Michael Van Canneyt <michael at freepascal.org> wrote:
> 
> I fail to see why you need management operators for this.

just because I wanted the array implementation available and to get automatic cleanup. I don’t know all the stuff dynamic arrays do behind the scenes and that worries me (see below).

> 
> If you declare your array in the record as a dynamic array, everything
> will be done for you.
> 
> The array is private. This means that the reference count will be 0 or 1.
> When the record goes out of scope, the compiler code will free it.
> 
> Unless I missed something which is always a possibility.

The ref counting is basically useless right now because the record needs to be passed by reference. All the internals like the ref count need to be stored as a pointer I think but I wanted this to be bare-bones and fast. Anyways it’s really just for single functions or globals, otherwise I’d use a class.

Mainly I just thought it was cool FPC can finally do this and if you wanted to you could make a robust implementation that did real ref counting. I had the problem with thread locking code getting called and killing performance so I won’t use dynamic arrays anymore because I don’t trust them. Using management operators with manual memory allocation gives you access to the implementation also in case you need to change something or need performance tuning (distrust of dynamic arrays really drives this idea for me). If I want to change something about dynamic arrays implementation it’s probably impossible for me personally to figure it out.

Regards,
	Ryan Joseph




More information about the fpc-pascal mailing list