1. I assume you mean multiple nested if-statements. No it's not bad practice and sometimes it's necessary. However, if a statement has too much logic and can be packaged into a function call, then do that.
If you mean ternary operator chaining, then Simba has no such thing.. IE:
Java Code:
int x = y > 0 ? z < 1 ? 9 : 8 : 10;
//same as:
int x = 0;
if (y > 0)
{
if (z < 1)
{
x = 9;
}
else
{
x = 8;
}
}
else
{
x = 10;
}
2. You cannot initialize multiple variables at the same time in a single statement. You can do something like:
Simba Code:
var
x: Integer = 0; y: Integer = 1; z: Integer = 2;
which is the same as:
Simba Code:
var
x: Integer = 0;
y: Integer = 1;
z: Integer = 2;
or
Simba Code:
var
x, y, z: Integer;
begin
x := 0;
y := 1;
z := 2;
x := y := z := 0; //initialize all to 0.
end;
3. Who said to keep all of them local? Keep them where they're supposed to be. If the variable is used by the entire script, then it is a global variable. IE: Constants (although constants aren't "variables". They are constant.
For example, Bitmaps.. If they are used throughout the entire script, why not load the bitmap once (stored in a global variable).. and some time before the script terminates, free the bitmap.. This way, you aren't loading a bitmap every function call (Local scope)..
3b. No there is no performance difference. Simba is interpreted. Not compiled. I doubt you'd see any difference in a compiled language as well.. Besides.. that's MICRO-OPTIMIZATION which is frowned upon in any programming language unless you absolutely 100% need every "bit" of performance you can get (IE: Micro-controller programming and Game-Programming, etc)..
4.
Simba Code:
var
rooms: Integer = 0;
students: Integer = 30;
begin
if ((rooms > 0) and (students / rooms > 30)) then
begin
//...
end;
//What this actually does..
if rooms > 0 then
if students / rooms > 30 then
writeln('blah');
end;