On Monday 08 May 2017 14:11:28 Marcos Douglas B. Santos wrote: > On Mon, May 8, 2017 at 2:39 AM, Martin Schreiber <mse00...@gmail.com> wrote: > >> > One does not need to use "class", it can be removed. I thought that > >> > people comming from Free Pascal will like it. ;-) > >> > >> You could be right, but I think they will like more if not exist > >> ambiguity. > >> > >> :) > > > > Other opinions? Should "class" be removed? > > Well, if ^TObj is the same as class and you will continue using this > syntax then, yes, I think class should be removed. > But maybe we should think more about it. > In order to clarify the difference of "object" and "class": "object" can be allocated on stack or on heap. "class" is an object which always is allocated on heap -> it always must be instantiated by a call of a constructor by <classtype>.TheConstructor() and it must be destroyed by a call of a destructor by <instancepointer>.TheDestructor() and it has an implicit dereference for element access. " type objty = object f1: int32; f2: int32; constructor create(); destructor destroy(); end; pobjty = ^objty;
TObj = class(objty) end; constructor objty.create(); begin end; destructor objty.destroy(); begin end; var obj1: objty; //an instance on stack, needs no create() or destroy() obj2: ^objty; //on heap obj3: pobjty; obj4: TObj; //on heap begin obj1.f1:= 123; //no create() call necessary, no destroy() call necessary obj2:= objty.create(); obj2^.f1:= 123; //note the '^' dereference obj3:= objty.create(); obj3^.f1:= 123; //note the '^' dereference obj4:= TObj.create(); obj4.f1:= 123; //no '^' dereference obj2.destroy(); obj3.destroy(); obj4.destroy(); " Martin ------------------------------------------------------------------------------ Check out the vibrant tech community on one of the world's most engaging tech sites, Slashdot.org! http://sdm.link/slashdot _______________________________________________ mseide-msegui-talk mailing list mseide-msegui-talk@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/mseide-msegui-talk