Hacking "method variables"

Frank Heckenbach ih8mj at fjf.gnu.de
Mon Jun 12 11:39:26 CEST 2006

> Forwarded from marcov at stack.nl (Marco van de Voort):
> In gmane.comp.compilers.gpc, you wrote:
> > Frank Heckenbach wrote:
> >> 
> >> begin
> >>   bla:=xx.methodname;
> >> end;
> >
> > So IIUC, the difference to Markus' way is that here the procedural
> > variable also contains the object, while there it only points to the
> > method, and can be applied to any object (of matching type), right?
> Yes, though object-instance might be a better phrasing.

Yes, I mean an instance.

> It works though with
> uninitialised objects too as long as you don't actually "use" (dereference)
> self:

I see. But I suppose Markus also wants to call the method via the
procedural variable later and apply it to a certain object instance
(selected at call time), something like (depending on the syntax

  someotherx.y (5);


  y (someotherx, 5);

> I'm a bit worried that this syntax is a bit focused on object types that are
> already (implicitely) a pointer, like Delphi.

For the syntax, adding a @ or ^ here and there should be all that's

> If this is possible with (one of ) your object models, better warn if you
> try to assign a methodvar to a method of an object that is on the stack
> instead of on the heap.

Of course, that can be a problem -- as always if not carefully used.
BTW, do you warn if taking the address (@) of a normal (non-object)
variable on the stack?


Frank Heckenbach, frank at g-n-u.de, http://fjf.gnu.de/, 7977168E
GPC To-Do list, latest features, fixed bugs:
GPC download signing key: ACB3 79B2 7EB2 B7A7 EFDE  D101 CD02 4C9D 0FE0 E5E8

More information about the Gpc mailing list