Forum > Beginners

What is the difference between the new ADVANCED RECORD and the old OBJECT?

<< < (12/12)

devEric69:
Wow! Thank you, for this programming lesson.

SymbolicFrank:
A class / object / advanced record is basically a block of memory with an index to show where the different parts reside. Methods are just functions / procedures that have an invisible @self pointer as first parameter. So, nothing is stopping you to allocate simple records on the stack and access them through pointers. In the past, before classes existed, I put all of the parts in linked lists, so it was easy to inherit and with an optional index to access the larger ones faster. Which is basically what a modern class is, although the compiler magic hides the pointers and packs them into arrays.

PascalDragon:

--- Quote from: devEric69 on October 21, 2021, 10:11:09 am ---Btw, @Serge writes constructor Init and not constructor Create in the records. I think it's probably to disconfuse between "constructors", whether it is an object instance (Create, i.e. located in the heap) or an advanced record variable (Init, i.e. located in the stack).
--- End quote ---

You can name the constructor method any way you want, even for classes. The only exception is if you want to override an existing constructor then you need to use the same name, but otherwise you're free to use Init in a class as well.


--- Quote from: devEric69 on October 21, 2021, 03:08:58 pm ---So, as far as I understand, nothing magic in memory allocation, including with this advanced records and their "constructor Init" (that said, it - the compiler - still does a lot of work for us in the background to automatically manage a specialized "type safe" container-list-map-..., even with these advanced records).
--- End quote ---

That management indeed has nothing to do with advanced records or not, it's simply related to whether you use e.g. AnsiString, Variant or IInterface.

Navigation

[0] Message Index

[*] Previous page

Go to full version