[fpc-devel] Advanced objects

Ryan Joseph genericptr at gmail.com
Fri Jul 24 04:00:15 CEST 2020



> On Jul 24, 2020, at 6:07 AM, Kostas Michalopoulos via fpc-devel <fpc-devel at lists.freepascal.org> wrote:
> 
> There should be at least support for operators. I have a custom
> dynamic array object type (i use objects instead of classes to avoid
> unnecessary heap allocations) which would benefit a lot from such
> support. I worked around not having management operators by putting
> the data fields and core functionality inside a generic advanced
> record which implements these operators and then using that inside the
> object (so the values do get released automatically when the object
> itself is released), but i also need support for at least the equality
> operator as the dynamic array object has an IndexOf method that uses
> that and it cannot be used with other dynamic arrays (so i cannot have
> a dynamic array object which itself contains dynamic array objects
> because i cannot provide a = operator for the dynamic array object
> itself).

I thought the core team was going to accept this patch because it doesn't really have any downsides. Classes should be able to support operator overloads also provided they don't return the class type itself (this was discussed at length with Sven) so at the very least =, >, < etc... should be supported. If the first patch ever gets accepted I would like to extend it to do that also.

Regards,
	Ryan Joseph



More information about the fpc-devel mailing list