On Mon, 4 Jun 2018, Ryan Joseph wrote:

Since we were talking about dynamic arrays I was curious to see if they could 
be implemented using the new management operators so I made a little proof of 
concept by cobbling together old code. It’s not complete or very good by any 
means but I think it’s a pretty interesting alternative to using dynamic 
arrays. Being able to add operators and methods is nice, especially since type 
helpers (that we could use on dynamic arrays) are so limited by single scopes 
currently. Specifically it’s nice to just declare an array and say “a += 1” 
without anything else. Having the implementation in a unit is good also in case 
you need to mess with something for specific performant reasons.

Not sure if this is useful or not but it’s certainly a milestone for Pascal to 
be able to make complex data types that integrate so well into the language and 
are so easy to use and manage.

https://github.com/genericptr/Managed-Arrays-Dictionaries

I fail to see why you need management operators for this.

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.

Michael.
_______________________________________________
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Reply via email to