in reply to Setting Globals in a Base Class

It seems like the correct solution would be for Foo to provide setter methods for these variables, which your class can call in a constructor. Otherwise, you have to know far too much about the implementation of Foo.

Replies are listed 'Best First'.
(Ovid) Re(2): Setting Globals in a Base Class
by Ovid (Cardinal) on Nov 07, 2001 at 03:14 UTC

    That would be a lot cleaner, but there are no such methods and any code that I produce can't rely on them, due to backwards-compatibility requirements. Sigh... Even if those methods werre available, my constructor may never get called as the the methods can be used as functions.

    I'm seeing some issues with dragonchild's solution, but it certainly seems like the only workable prospect (and it's pretty cool, too).

    Cheers,
    Ovid

    Update: Hmm... or I could create the mutators myself and add them to Foo's symbol table.

    Join the Perlmonks Setiathome Group or just click on the the link and check out our stats.

      Ick. I don't mean this as an insult (I'm sure it was nothing but a wild idea), but that's a pretty Microsoftian way of thinking, with Foo offering a modified interface when Bar is loaded (for some reason it makes me think of the MSOffice installers upgrading half your OS behind your back). Also you gain nothing because to modify Foo, Bar still has to know far too much about it.

      So I suggest you rather not go there :)