Advanced Scripting Documentation

You're misreading the documentation.

Calling another script from within a script is not the same as importing a script and making use of its functions. That sentence is referring to executing a script from within a CLI script (or using cli_execute() to call a script from withing an ASH script).
 
So what do we think Hola(?) meant when he wrote
You should not, however, "call" other ASH scripts from within an ASH script, as this yields unpredictable results.

My login script is riddled with lines like

Code:
ok = cli_execute("call leaderboard.ash");
print(" ");
ok = cli_execute("call LastPost.ash");
print(" ");
ok = cli_execute("call CheckSkel.ash");
print(" ");
print("Login script finished.");

I have not had any problem that I recognized as such. Have I been lucky or is the warning OBE or is there a performance hit I'm taking that I could eliminate or ???
 
So what do we think Hola(?) meant when he wrote

What happens when, using this, script A calls script B, which calls script C, which calls script A?
(let's assume that the final invocation of A avoids calling any other scripts).
Does the second invocation of A have its own interpreter?
If not, then the second calling of A will have some side-effects that will do something when control returns to the first A. Are those predictable?
 
Every script has its own interpreter, and if you invoke it recursively, as you describe, both invocations will share the same interpreter. That is almost guaranteed to be a Bad Thing. We do synchronize on the interpreter object, but that only keeps multiple threads from being in it at the same time, but the case you describe uses the same thread and will not be excluded.

"Blocking until the interpreter is relinquished" is certainly not what you want in this case, anyway. You either want a brand-new interpreter or a hard error that aborts the script.
 
OK. In my specific case I'm not seeing any issues because each of the scripts I execute via cli_execute is self contained in that they don't call any other scripts. But it seems like the safest practice would be, as advised, to import the scripts and then invoke specific routines. Thanks.
 
Back
Top