Why so much verification in scriptin

Started by
3 comments, last by lollan 14 years, 2 months ago
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
Working with 3d Rad. Angle Script code.
Advertisement
Because checking for (and handling) errors is good development practice.
Dose not help much.
Working with 3d Rad. Angle Script code.
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.
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 ^^

This topic is closed to new replies.

Advertisement