Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!usc!zaphod.mps.ohio-state.edu!uwm.edu!psuvax1!rutgers!njin!princeton!taylor!ssr From: ssr@taylor.Princeton.EDU (Steve S. Roy) Newsgroups: comp.lang.c++ Subject: A question about run time binding. Message-ID: <1249@idunno.Princeton.EDU> Date: 17 Jul 90 02:20:39 GMT Sender: news@idunno.Princeton.EDU Reply-To: ssr@taylor.Princeton.EDU (Steve S. Roy) Organization: Princeton University Lines: 33 This came up writing a code that needs to do a possibly remote procedure call as efficiently as possible in a Hypercube. There is a network of "nodes" which do computation and talk to other "nodes" across "links". There are typically many nodes on each "processor" and that provides fast "communication" among those nodes, but if a node needs to talk to someone on another processor, a remote procedure call is invoked. When I want another node to do a computation with data that I have, I would like to say: this_node.FindOtherNode().DoComputation(data) where this_node is the current node, FindOtherNode decides whether the other node is near or far and then returns a type that DoComputation uses to either do a calculation on this processor using data or send a message (including the data) to another processor to do a calculation. As I understand things, FindOtherNode would have to return a structure general enough to include either a near node reference or a far node reference (potentially very different) and a boolean which DoComputation could use for an if statement. Is this correct? I can see that you could write by hand a union that includes the two (or more) possible classes plus the flag and test it yourself, it would just be nice if the compiler would do that for me. It seems like much of the point of C++ (and OO in general) is to avoid forcing the user to branch on a flag that indicates the type of an object. Steve Roy ssr@acm.princeton.edu