Why so much verification in scriptin
I notice from many script there is verification like:
-- Here it check if the variable is not nil.
local s = application.getCurrentUserScene ( )
if ( s ~= nil )
Thanks
Most scripting languages are quite dynamic. Variables and functions are created on the fly at runtime. It becomes far more difficult to do static analysis of basic errors like those available to more structured languages.
A lot of checks (variables existing, function argument existance and type matching) that would be caught in a separate compile pass need to be checked at run time in most scripting languages.
This is the price you pay for rapid development and using higher level features in the scripting language.
A lot of checks (variables existing, function argument existance and type matching) that would be caught in a separate compile pass need to be checked at run time in most scripting languages.
This is the price you pay for rapid development and using higher level features in the scripting language.
Assuming that everything will go according to plan in programing can be quite risky especially in dynamic envorionement.
Like rip-off said, scripting languages allows a lot of flexiblity especially at run time, therefore you should not assume but you should check.
In short better be safe than sorry.
It's common good pratice, of course you're free to not do it ^^
Like rip-off said, scripting languages allows a lot of flexiblity especially at run time, therefore you should not assume but you should check.
In short better be safe than sorry.
It's common good pratice, of course you're free to not do it ^^
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement