[fpc-pascal] Managed record questions

Ryan Joseph ryan at thealchemistguild.com
Fri Mar 9 04:43:57 CET 2018



> On Mar 9, 2018, at 10:32 AM, Michael Van Canneyt <michael at freepascal.org> wrote:
> 
> Why don't you use objects ? No-one has obsoleted this, and you get what you
> want: an object that can be allocated on the stack or on the heap.

Object is just for backwards compatibility right? Does it support new features like generics, helpers, overloads  etc…? I have read over the years they’ve been broken also so I just assumed they were a dead part of the compiler kept around for old projects. If they still worked then why introduce “advanced records” which are merely “basic classes”. :) As pointed out it doesn’t make sense that classes and records diverged in the way they did.

> 
> I'm sure that we can add some extension to it to get rid of the somewhat awkward
> new(someobject,init)
> syntax to allocate one on the heap.

If they’re not dead, then yes, making objects more flexible is possible but making classes behave like records on the stack is not. The best we can do now is use management operators on generic records to wrap classes so they get deallocated when out of scope. I can’t believe how complicated we’ve made things. :)

Regards,
	Ryan Joseph



More information about the fpc-pascal mailing list