Path: utzoo!censor!geac!torsqnt!news-server.csri.toronto.edu!cs.utexas.edu!samsung!rex!wuarchive!usc!elroy.jpl.nasa.gov!ncar!boulder!uswat!csn!tigger!streich From: streich@tigger.Colorado.EDU (Mark Streich) Newsgroups: comp.lang.pascal Subject: Re: TP5.5: Can't store method in procedure variable Keywords: Method Object Procedure TP5.5 Message-ID: <1990Dec7.153019.23716@csn.org> Date: 7 Dec 90 15:30:19 GMT References: <1990Dec3.061013.22258@ux1.cso.uiuc.edu> <1990Dec4.232438.927@ux1.cso.uiuc.edu> <1990Dec6.143527.21330@watserv1.waterloo.edu> Sender: streich@tigger.colorado.edu Followup-To: comp.lang.pascal Distribution: na Organization: University of Colorado, Boulder Lines: 34 Nntp-Posting-Host: tigger.colorado.edu dmurdoch@watserv1.waterloo.edu (D.J. Murdoch - Statistics) writes: >You seem to be allowed to do it [get address of object method] 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. This looks quite suspicious because you're taking the address of a class, and not the address of an *instance* of the class. Two instances may (obviously?) have different virtual methods. As a comparison, it looks like you're taking the address of the integer type rather than an integer variable. (i.e., p := @integer rather than p := @i { of type integer }) Does this run correctly with different instances of the object? Mark Streich streich@tigger.colorado.edu