Peter Gerwinski wrote:
New(Foo); Foo.Create;
If it's undefined in Delphi, it wouldn't hurt if there is a defined behaviour in gpc. :-)
You cannot `New' a class because it is a reference, no pointer. The above should be a syntax error in GPC as well as in Delphi.
I meant the "Foo.Create" which could be allowed in gpc, I overlooked the "New(Foo)" line which in fact wouldn't make much sense.
That's the anti-motivating part of compatibility: All this is intended *not* to be used.
Yes, but we basically have the choices to say "you must convert this and this and that before your programs will compile with gpc, then they won't compile with BP anymore, but you can do much better things", or "you can just compile most of your BP programs with gpc, and once you're convinced that gpc really does its job, you can make use of more advanced features as fast as you want to" -- I guess most BP users would accept only the latter way...
Nice little "trick", but not very systematic. "Free" is a method of an object, and this object can be "nil^"!? Technically, it works, but "Free" must not be virtual (I guess it isn't in Delphi)! But as a clean way, I'd prefer a procedure... (Or should we regard it as defined behaviour to call a static method of a non-existing object if the method doesn't access any fields of the object?)
Sorry, but this nice little trick is purest brain-damage!
Doesn't matter since Delphi runs only under Windoze -- there's nothing to damage... ;-)
- Dereferencing a `Nil' pointer should yield a runtime error. Both BP and GPC don't check this, but this is a bug in the compiler to be eliminated when we implement runtime checks into GPC.
A very good idea!
- Releasing the storage of an object while a method of it is running is idiocy. It should yield a runtime error, too, but this is too hard to detect for the compiler.
True. But I fear a Delphi compatibility library will even have to emulate this... :-(
(BTW: Since OOP objects are often compared to real world objects or persons, this "Free" method would mean: 'Commit suicide, and bury your own corpse, please!' ;-)