Interdependent modules?

Jeremy Gibson jtgibsontelusnet
Mon Jun 19 18:18:46 PDT 2006


I have a pair of modules which need one another's functionality, and I've been
poring through the documentation on trying to figure out how to get them working
together, to no avail.  The structure is basically as follows (with unnecessary
baggage trimmed out):

gameobject.d
============
import data (for ac_data class)
class ac_object : ac_data

data.d:
=======
import gameobject (for ac_object class)
class ac_data
class ac_location : ac_data
class ac_region : ac_location
function ac_region.Contains(ac_location location)
function ac_region.Contains(ac_object object)


Naturally, the compiler doesn't like this kind of cross-dependency of modules.
However, being a total newbie doesn't help me find an answer, so I thought I'd
resort to the experts.

How can I define a Contains() function override for the ac_region class that
accepts an ac_object as a parameter?  Is it possible to get the
ac_region.Contains() function to safely operate on an ac_object (which is
deliberately defined in a different module) without having to remove the
function from data.d?

I'd prefer not to define the ac_region functionality in a seperate module
because it should be a part of the standard suite of data types conferred by the
"data" module.  I always could define it seperately if absolutely necessary,
though I'd secretly hate myself... =P





More information about the Digitalmars-d-learn mailing list