Sometimes a bug, sometimes a feature.
I think It is cool to know that you can have “universal” variables.
But, in most cases the shared scripting environment poses as a bug. Like when you for instance link scriplibraries into scripts with Script Debugger. Then, if you load, then run a script from within another, you get at best a warning about the conflict. Run script avoids this since a brand new scripting environment is created… Run script must also be faster than the two combined statements. Though I am not sure what is worst, creating a totally new scripting environment, or adopting to the one that is already there.
One thing is sure, when for some reason either the current scripting environment is “littered”, or there are too much to take into account in it, like if you have and applet, or run a script from the script menu, then it speeds the process considerably by running the script. I think either ways are good here, using run script, or load it, or just tell it to run if it is present in the script file. I tend to use the latter construct with success.
Now, if the same property are declared in the top level of a script, and that property holds a scriptobject, then I think the library becomes shared, so that you end up with just one instance, and a slightly lower memory imprint during that particular execution, that way the bug is a feature, as long as your libraries are definitively static, and doesn’t save any values from the running script. Libraries - not Script Objects that does a task and saves some values, if you understand what I mean.
As far as I have figured it, the only way to evaluate stuff into records and such is by the run script statement.
I think I am all done with the subject by now. I do agree that in most cases it is a pitfall, but at the same time, it is one of those “dirty” “dirty” things that makes AppleScript so intriguing.
Edit The best thing about this, is that I then can have a script call a script call a script, without having to be concerned about the shared propertynames, that should presumably call the same library. Now, there is a conflict there, if the library has been updated between the differerent scripts I guess. So, making it all work this way will make me have to build dependencies as I update libraries. Which is a big pitfall to the scheme really.
But . if I assigned the script libraries to globals, so that they would load each and everytime, it would sure impede speed penalties, but I would always load fresh code, and my script could coexist with others in a call chain, and be executed independently!