Migrating from Scilab 5.5 to Scilab 6

With the release of Scilab 6.0.0, Scilab possesses a new kernel, a new interpreter, and a new parser. All these changes broke some compatibility with regard to Scilab 5.X family.

This page provides details and examples of the changes in the language and syntax between Scilab 5.5 and Scilab 6. The goal here is to list all changes that can have an effect on existing code, and how to update scripts. Although this page may still be incomplete, porting scripts from Scilab 5.5 to Scilab 6 should not represent an important effort, and should be relatively straightforward.

For a complete list of change between Scilab 5.5 and Scilab 6.0, including not only language changes, but also all other changes, see the 6.0.0 CHANGES documentation file.

1. Syntax modifications

1.1. Linebreaks

Declaration of a numerical value on two lines with a linebreak is no longer possible.

   1 1...
   2 2
   3 // yields an error

1.2. Operation ./

Operation ./ is now parsed properly when used with integer values.

1.3. String delimiters

Declaration of strings using non homogeneous delimiters '" or "' is no longer possible.

1.4. Operator ==

(a=b) is no longer interpreted as (a == b).

1.5. function...end or function...endfunction

Function definitions can be done with end instead of endfunction

   1 function ret = foo()
   2     ret = 42;
   3 end
   4 // function is properly parsed

1.6. Recursive extraction foo()(1)

Recursive extraction is now possible for Scilab 6 structures.

   1 plot2d();
   2 gcf().children(1); // returns the first child of current figure
   3 
   4 linspace(1, 10, 20)($-4:$) // returns the 5 last values of linspace(1, 10, 20)

1.7. Deprecated {} for matrix definition

Matrices can no longer be defined usind {} operators. These are reserved for cell definition.

   1 a = {1:10} //creates a array of 1-by-10 cells containing values 1, 2, 3, ... , 10

See cells for more information.

1.8. Shortcut && and || vs element-wise & and |

Shortcut and element-wise boolean operators are now distinguished. && and || are new shortcut boolean AND and OR while the former & and | are element-wise operations and will not shortcut one of the operand. Both shortcut and element-wise operators are evaluated from left to right.

   1 a = 5;
   2 b = 42;
   3 
   4 function ret = foo(val)
   5     ret = val + 100/val;
   6     disp("entered this foo function");
   7 endfunction
   8 
   9 (a < 6) || (foo(b)< 10) // will not enter foo()
  10 (a < 6) | (foo(b)< 10) // will enter foo()
  11 
  12 (a >= 6) && (foo(b) < 10) // will not enter foo()
  13 (a >= 6) & (foo(b) < 10) // will enter foo()

--> (a < 6) || (foo(b)< 10) // will not enter foo()
 ans  =

  T


--> (a < 6) | (foo(b)< 10) // will enter foo()

 entered this foo function
 ans  =

  T



--> (a >= 6) && (foo(b) < 10) // will not enter foo()
 ans  =

  F


--> (a >= 6) & (foo(b) < 10) // will enter foo()

 entered this foo function
 ans  =

  F

2. Empty matrices operations

Adding or subtracting the empty matrix now returns the empty matrix. This change was done to harmonize the behaviour of operators with regard to the empty matrix.

   1 // These operations are very different in Scilab 6 vs Scilab 5
   2 1 + []
   3 1 - []
   4 [] + %s
   5 [] + "Some text"

To handle difficult situations where the code was using this behavior, a warning is issued when an operations with the empty matrix would give different results. A new warning("stop") mode is available to stop the execution when a warning is encountered and give the line the operation is encountered.

   1 warning("stop");
   2 1 + []; // will stop the execution
   3 warning("on")
   4 1 + []

public: FromScilab5ToScilab6 (last edited 2017-02-28 14:09:23 by proxy)