Chapter 4. Unknown Spots

Table of Contents
4.1. Keywords and Commands
4.2. Operator Overloading[1]
4.3. Operator Precedence And Associativity
4.4. Implicit Cast To Boolean
4.5. Integers by Enrico Segre
4.6. Miscellaneous Unknown Spots

In this chapter we shed some light onto widely unknown features. Parts like the operator precedence unconsciously are exploited in every-day programming by all of us. Others, like integer variables are easily misused. So, read on and become a Yedi^H^H^H^HScilab master.

4.1. Keywords and Commands

The Scilab language protects only twelve words against any modification by the user. These identifiers cannot be used as variables or function names. Any attempt to do so immediately raises an error, which typically reads "incorrect clause".

Table 4-1. Reserved Words

Name Description
break Force (premature) exit from a for or while loop
case Start clause within a select statement
do Synonym for "," after for, while, if, etc.
else Start alternative in an if or case statement
elseif Add a conditional branch to an if statement
end Terminate for, if, select, and while statements
endfunction Terminate a function definition
for Start a loop with a known number of iterations
function Start a function definition
if Start a conditional
select Start a multi-branch conditional
then Synonym for "," after expression in if or select

Reserved words are protected against abuse by the interpreter, commands which follow in Table 4-2 are not! Some of the commands ought to be reserved words, but they are not. Commands can be used in contexts where variables are valid, however, the results are surprising. Therefore they should not be used as names for variables or functions.

Table 4-2. Commands

Name Description
abort Stop current evaluation and return to primary command-level
apropos word Search for manual-pages whose synopsis matches word
clear varname Remove variable (or function) varname from workspace; see also Section 2.5.3
exit Terminate Scilab sesssion
help word Display manual page on topic word
pause Switch into pause mode (can be used multiple times)
pwd Print the current working directory
quit Jump out of pause mode (can be used multiple times) or quit Scilab session
resume Stop execution of a function or, in pause mode, return from function
return Return from function
what List all Scilab reserved words
while Start a conditional iteration
who('local' | 'global') List local or gobal variables in workspace; see also Section 5.2.1

Some uses of do:


for i = 1:n do ..., end

while i < n do ..., end

if a < b do ..., else ..., end