RobertL wrote:There is no function in that script
So add one!
And I think it's more efficient to use MyClass[a](b) directly in any where at any time, without thought to put #Include<MyClass>, or first call a function from that script.
You don't need to think about it
. Just make the usage of your class like this:
after defining the MyClass() function as in my previous post. Is this not more efficient than using #Include <MyClass>
in each script which uses the class? On the other hand, it may be more efficient to always
#Include each library - although it requires more typing, it makes the script's requirements very clear, and doing it by habit means you won't need to debug your script when it fails due to not auto-including a file.
Of course, you can't do exactly that if you're just calling static methods of MyClass and not instantiating it. But if you're just calling static methods, there isn't really any benefit of using MyClass.Func()
(and there are performance penalties).
You don't have to call MyClass() before referring to MyClass. You just need the script to contain at least one call to that function. It doesn't even need to actually be executed.
I think variable and function (also label) are different mechanisms.
There may be duplicate name,
That's irrelevant. The reason new MyClass
can't auto-include is that MyClass
could be something defined by the script at runtime - the interpreter has to assume it already has everything it needs and does not need to include some other file.