On Mon, May 8, 2017 at 12:40 PM, Martin Schreiber <mse00...@gmail.com> wrote: > [...] > > No. Call it "manually": > " > obj1.create(); > obj1.destroy(); > " > or use "ini", "fini" methods: > " > objty = object > method theinimethod() [ini]; //called after object initialization > method thefinimethod() [fini]; //called before object finalization > end; > " > "ini" and "fini" work for stack and heap.
In fact, this is a good idea. But why don't use [initialization] and [finalization]? The IDE has code-completion so, is better to see a code more readable, don't you think? >> 2. In this case: >> obj2: ^objty; //on heap >> >> Is it possible to remove the "^"? >> obj2.f1:= 123; >> > No, obj2 is a pointer. > >> I think this distinction exists because "class" exists, right? > > The other way around, "class" exists for convenience and where one needs the > guarantee that the instance never is allocated on stack. I see... >> If is possible to remove, well, this is +1 to remove class and mantain >> just object but without "^" in calls, but we can continue using in >> definition. >> > And how to access object elements if they are allocated on stack and not > addressed via pointer? > > "@obj1.f1" or "obj1↓.f1" or...? You've already answered "No, obj2 is a pointer." but what about if the compiler change this by itself, putting a "^" because the variable declaration has one? var obj1: objty; //an instance on stack, needs no create() or destroy() obj2: ^objty; //on heap begin obj1.f1:= 123; obj2:= objty.create(); try // I did not write the '^' but the compiler will use because the declaration in VAR obj2.f1:= 123; finally obj2.destroy(); end; end; Marcos Douglas ------------------------------------------------------------------------------ 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