1. I am going through my addon and trying to clean up global pollution. I found that all of my form widgets were polluting the global namespace.

    I tried changing the names of the widgets to Foo.OKButton Foo.CancelButton etc, in an attempt to put all of the button objects into the local "Foo" object. It didn't work.

    Is it possible to setup frame xml so it won't pollute the global namespace?

    Thanks!

  2. Yes. Don't give them names, use parentKey. Like:

     <Frame name="Foo">
       <Frames>
         <Frame parentKey="bar">
         </Frame>
       </Frames>
     </Frame>
    

    Then you'll have Foo, and Foo.bar. This will not work with many of the Blizzard templates that expect/require names.

    'Global pollution' isn't real. The problem is when you accidentally make a global variable called 'result' or something generic like that. A frame called MonkeyNuts_Frame is not going to conflict with any other addon, so that's not really an issue.

    Globals do not slow anything down and don't cause any problems, so long as you can be reasonably confident that you're not colliding with another addon.

  3. Sorry for the bump, but the subject is exactly the topic I am digging into. I agree that in reality there should be a very low probability of collision, but I'm seeing some collisions either at the global namespace level or as things are being hooked (probably the bigger issue). Regardless, I'm trying to eliminate the first area before I tackle the second.

    If we apply your solution of just using parentKey, and then I want to set some other frames or buttons relative to this one within the XML is it possible? I played around a bit and it doesn't seem to like relativeTo="foo.bar". I tried a couple variation on "foo[bar]", etc but haven't hit on one that works other using the name instead of the parentKey.

    Has anyone seen a way to do this?

    //tasz

  4. Well, if you use $parentFooNames there shouldn't ever be any collision, that just wouldn't happen.

    There isn't a relativeKey attribute in WoW yet, but I've heard discussion (and seen code in the beta client) that seems to indicate that it is coming. If you need to set relative stuff right now, you'll need to use names or do that in an OnLoad script.

  5. Thanks for the confirmation, I really didn't want to pound my head against that for hours/days.

    //tasz