Path: utzoo!attcan!uunet!zaphod.mps.ohio-state.edu!uakari.primate.wisc.edu!aplcen!haven!cs.wvu.wvnet.edu!cerc.wvu.wvnet.edu!cathedral!kerrin From: kerrin@cathedral.cerc.wvu.wvnet.edu (Kerrin Smith) Newsgroups: comp.lang.c++ Subject: Request for help in simulating an interactive system Keywords: c++, g++, interactive Message-ID: <935@babcock.cerc.wvu.wvnet.edu> Date: 22 Oct 90 18:17:56 GMT Sender: news@cerc.wvu.wvnet.edu Lines: 35 I am in the process of developing a constraint management system in G++. I am interested in being able to dynamically load constraints of a form such as X = Y + Z, where X, Y and Z are variables. Upon recognizing a variable, I will create a new "variable" object. Here is where my problem lies. I would like to be able to *bind* the variable name, say X, to the newly created object so that later I can reference it directly simply by using the name X. Now, I know that I can store the character string X in the newly created data structure, however, an exhaustive search through some list would then be required for each access. I could create enough pointers to variables initially and give them names that I know will occur. As each variable is created I can point the existing variable pointer to the appropriate object. The problem with this is that I won't know the variable names or how many variables there will be in advance. The best method I've come up with is to create a hashing function to map the variable name to the new variable object. This solution is okay but it requires a function call for each variable access. Instead of being able to say R = X + Z, I'll be required to say something like, MAP(R) = MAP(X) + MAP(Z). I know that what I am trying to do is exactly what separates interpreters from compilers, but it seems as though there must be a more elegant method to simulating an interactive system. Any advice or references would be greatly appreciated. Kerrin Smith Graduate Student School: West Virginia University Work: Concurrent Engineering Research Center Kerrin@cerc.wvu.wvnet.edu