I suppose my initial example wasn't the greatest. Here's a better example of what I'm trying to do.

module a;
class A : SuperA
{
    B b = new B();
    C c;
    D d;
    //...

    this()
    {
        b.loadInteralStuff("filepathofstufftoload");
    }

    void doStuff()
    {
        int var1, var2;
        char var3;
        int[] var4;
        File var5;

        //read and parse stuff from a file...

        //found commands that need to be executed, although
        //this class only knows that they are a set of commands
        //not what they actually do (and shouldn't)
        b.executeCammands(commandArray);
    }

}

module b;
class B : SuperB
{
    SomeComplexDataStructure data;

    //private helper functions

    void loadInternalStuff(string filename)
    {
        //load a file in a certain way. This implementation
        //could be subject to change which shouldn't affect A
    }
    void executeCammands(byte[] commands)
    {
        //execute each command, most of which need to edit
        //the local variables of doStuff() but should be
        //implemented in this class

        //in most cases, the local variables needed could be
        //similar to any implementation but are different enough
        //for it to be a major annoyance to pass every possible
        //variable needed to this function by reference
    }
}

It would be convenient to have a way to either specify that a function can be called only by a specific function and have access to it's local variables or overload a function to provide a specific implementation for certain functions.

Reply via email to