Newsgroups: comp.lang.pascal
Path: utzoo!utgpu!watserv1!dmurdoch
From: dmurdoch@watserv1.waterloo.edu (D.J. Murdoch - Statistics)
Subject: Re: TP5.5: Can't store method in procedure variable
Message-ID: <1990Dec6.143527.21330@watserv1.waterloo.edu>
Keywords: Method Object Procedure TP5.5
Organization: University of Waterloo
References: <1990Dec3.061013.22258@ux1.cso.uiuc.edu> <1990Dec4.232438.927@ux1.cso.uiuc.edu>
Date: Thu, 6 Dec 90 14:35:27 GMT
Lines: 30

In article <1990Dec4.232438.927@ux1.cso.uiuc.edu> dslg0849@uxa.cso.uiuc.edu (Daniel S. Lewart) writes:
>I believe that this is the correct explanation of my problem.  My last question
>is whether @ can be applied to an object method.  The OOP Guide says 'yes', but
>my experience says 'no'.


You seem to be allowed to do it if you specify the method with a type prefix,
but not with a variable prefix.  For example:

type
  myobj = object
    constructor init;
    procedure static;
    procedure virt; virtual;
  end;
{  code for init, static, and virt omitted... }

var
  o : myobj;
  p : pointer;
begin
  p := @myobj.static; { these first two work }
  p := @myobj.virt;
  o.init;
  p := @o.static;     { these last two don't compile }
  p := @o.virt;
end.

Duncan Murdoch

