records with methods are handy, the only thing I do not understand is why they are not inlined by the compiler when they are marked so....
records with methods are handy, the only thing I do not understand is why they are not inlined by the compiler when they are marked so....
The only useful addition I see is sealed classes/methods.
Inlining of course useful as well, but it's not working in most important cases (assembler functions).
Yes, Records with Methods are basically classes. The difference is in the VMT and how its transported with the data-structures. Though, Records with Methods isn't anything new, its been around since records and method pointers existed . CG just made it "easier" to utilize.
Personally, I'd be more interested in seeing the list of things that Borland (I can't say CG yet) screwed up or didn't do since Delphi 7 that the developers (users) strongly pushed for. This listing is greater in length then what they have done right overall.
On the topic of CG, I see the same bad habits starting to show in CG as were found in early Borland. Bad marketing, poor target focus, and "new features" that were lightly requested if requested at all. I'll give credit where credit is due though, integrating FastMM and other freeware solutions into the distro with full native support was a good move.
- Jeremy
http://www.eonclash.com/
Well, the difference between records with methods and classes is clear to me. What is absolutely not clear to me is the difference between objects and records with methods.
About focus: CG has clearly started work on 64-bit and Unicode-VCL, and has been busy with Vista support too. This is a *lot* of work, it is too early to make conclusions here.
An object has a VMT (Virtual Method Table) so that all objects point to the same methods. Change the root method and you change it for all objects. In a record with methods there is no VMT thus the record contains a full copy of the method itself. Changing the method in one record does not affect the other records of the same type.
- Jeremy
http://www.eonclash.com/
This is incorrect:
[pascal]
type t1=object
a,b:word;
end;
[/pascal]
... is binary equivalent to:
[pascal]
type t1=record
a,b:word;
end;
[/pascal]
Only when you add a virtual method, a VMT is added to the object.
I don't understand your reply about changing methods. How can you change a method in a running program?
You compared an orange to an orange since compilers are smart enough to optimize an object w/o any methods into a record. Compare it with a method in each and see if its the same. Unless something major has changed under the hood of Delphi then it shouldn't be.
As for changing the method on the fly, you have to change the method pointer to point to a new method or walk the method pointer to the code block and overwrite that block with a new instruction set. Its true polymorphic development.
I'm not going to get into exacts in this thread as its a complicated subject and is way off-topic.
- Jeremy
http://www.eonclash.com/
Ahh great find! Those class helpers looks interesting.
I've used operator overloading since I got Turbo Delphi and they are just so extremely nice. All my overloaded operators also work in fpc though.
I for some reason like the delphi implementation better even though the fpc implementation seems more powerfull as it isn't only bound to be sitting in a record already
Class properties are freaking nice. Now I can implement singletons without global variables
Peregrinus, expectavi pedes meos in cymbalis
Nullus norvegicorum sole urinat
No just class properties. These allow me to set a variable in all allocated classes of that type at one time.
I haven't understood the difference between class property and the static class property. Could anyone elaborate?
Peregrinus, expectavi pedes meos in cymbalis
Nullus norvegicorum sole urinat
Bookmarks