What is the disadvantage to importing functions into a scrip

Post » Fri Jun 22, 2012 1:25 am

http://www.gamesas.com/topic/1381253-what-is-the-disadvantage-to-importing-functions-into-a-script/page__view__findpost__p__20929622
I think it's safe to assume the only difference will be the syntax in the psc and once compiled both calls will be equal (as said I assumed it, didn't decompile it to check). But once you decide to test it, I think you should check the difference with a call to an imported function and to the same function the usuall way *without* it being imported previously (obviously it can't be done in the same script, but a script could call two different scripts one with the first method and one with the second one, being both secondary scripts equal otherwise).
User avatar
Amber Ably
 
Posts: 3372
Joined: Wed Aug 29, 2007 4:39 pm

Post » Fri Jun 22, 2012 1:24 am

I have just decompiled three variations of a script and can definitively say that all three of these produce identical runnable code. (The time a script is compiled and the line number of each command get embedded in the compiled version of the script for debugging so the actual PEX files are different, but the runnable code parts are identical.)

Event OnInit()	Debug.Trace("Hi")EndEvent
import DebugEvent OnInit()	Debug.Trace("Hi")EndEvent
import DebugEvent OnInit()	Trace("Hi")EndEvent

The world "import" in the case just means making their names available it doesn't mean pulling in all of their code. So go ahead, import and save yourself some typing. Or don't import and make it obvious to yourself which functions come from which script type. Either way works and it's just a matter of your preferred style.

I'm going to post this over in my http://www.gamesas.com/topic/1383987-performance-characteristics-of-papyrus-functions-and-operations/page__pid__20991319 thread too.
User avatar
Astargoth Rockin' Design
 
Posts: 3450
Joined: Mon Apr 02, 2007 2:51 pm

Post » Thu Jun 21, 2012 7:50 pm

Very interesting.. thanks! Like I said, I assumed it didn't actually import the whole script into memory or whatever... it just sounded like that would be the case heheheh. I'll be double-checking the raw data of some compiled test-scripts; then I'll stop using all that extra dramatic typing!
User avatar
Camden Unglesbee
 
Posts: 3467
Joined: Wed Aug 15, 2007 8:30 am

Previous

Return to V - Skyrim