Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!sdd.hp.com!zaphod.mps.ohio-state.edu!julius.cs.uiuc.edu!ux1.cso.uiuc.edu!uxa.cso.uiuc.edu!dslg0849 From: dslg0849@uxa.cso.uiuc.edu (Daniel S. Lewart) Newsgroups: comp.lang.pascal Subject: Re: TP5.5: Can't store method in procedure variable Keywords: Method Object Procedure TP5.5 Message-ID: <1990Dec4.174837.24879@ux1.cso.uiuc.edu> Date: 4 Dec 90 17:48:37 GMT References: <1990Dec3.061013.22258@ux1.cso.uiuc.edu> <2218@mentor.cc.purdue.edu> Sender: news@ux1.cso.uiuc.edu (News) Organization: University of Illinois at Urbana Lines: 39 garlange@mentor.cc.purdue.edu (Mark Garlanger) writes: > The question I have is WHY you would want to do this? Methods are closely > tied to the data structure associated with it. What would you want the > program to do with the method tries to access the data that the object has > defined? What you are trying to do would cause many ambiguities for the > compiler. I bet there is a way to solve your general problem by using > the object-oriented programming directly, such as using virtual methods. > I have done some work with objects and if you gave your general problem, I > may be able to offer some hints on how to do it. My intention is to use object methods in my menuing system. For each entry in a menu, there is a procedure which is executed when that entry is selected. This works for ordinary procedures, but it won't even compile for object methods. The example I posted was constructed to illustrate my problem as simply as possible. I don't see how there would be any compiler ambiguities, but I do hope you win the bet! In practice, my code for initializing each entry in a menu looks like the following (Name's are strings): AddItemProc( Name1, Proc1 ); AddItemProc( Name2, Proc2 ); ... I would like one of these Proc's to be an object method: AddItemProc( Name3, Obj.Method ); Currently, I have to resort to the following code: procedure ObjMethod; begin Obj.Method; end; AddItemProc( Name3, ObjMethod ); Thank you for your kind offer, Daniel Lewart d-lewart@uiuc.edu Brought to you by Super Global Mega Corp .com