Work at SourceForge, help us to make it a better place! We have an immediate need for a Support Technician in our San Francisco or Denver office.

Close

#199 non-local variables collide among Modules

v1.6
open
Chris Laurel
Core (65)
5
2008-07-04
2008-07-04
Selden Ball
No

This problem is seen in Celestia v1.5.1 and v1.6 built from svn.

Global variables (i.e. variables not prefixed by "local")
collide among the ScriptedOrbits and ScriptedRotations
of different Modules in different Addons.

They should not, since equivalent global functions do not collide.

This Addon demonstrates the problem.

The non-local variable global.var is declared at the top level of Addon_1's Module_1 and set to the value 1.

The non-local variable global.var is declared at the top level of Addon_2's Module_2 and set to the value 2.

Addon_1's Module_1's global.var is overwritten by
Addon_2's Module_2's statement
global.var = 2

It should not be overwritten.

I've attached a zip file of the Addons which demonstrate this issue.

A concern is that some unpublished Addons may be using this inappropriate functionality for inter-Addon communication. I must admit that I'm strongly tempted to do so myself.

I could not-so-reluctantly be persuaded that this functionality should be retained and documented.

Discussion

  • Selden Ball
    Selden Ball
    2008-07-04

    Addon demonstrating conflicting globals.

     
    Attachments
  • Selden Ball
    Selden Ball
    2008-07-04

    • milestone: --> v1.6
     
  • Chris Laurel
    Chris Laurel
    2008-07-04

    Logged In: YES
    user_id=159994
    Originator: NO

    This actually is the intended behavior. I believe that the scripts used by CNES are taking advantage of the shared namespace for variables. I don't want to break these scripts. I agree that while useful, the name collisions are an undesirable consequence. One way to resolve the problem may be to add a new boolean parameter for ScriptedOrbit and ScriptedRotation: SharedNamespace. It would default to true so as not to break existing scripts. Some mechanism for communication between scripts would still be nice even for scripts that don't share a namespace.

     
  • Selden Ball
    Selden Ball
    2008-07-04

    Logged In: YES
    user_id=662401
    Originator: YES

    A boolean to control this would be fine, but I'd quibble over the name.
    SharedNamespace implies to me that the functions are shared, too, which probably is not the intent.

    SharedVariablespace perhaps?

    s.