BUG DESCRIPTION:
----------------
The m2sci code converter -- noticeably its engine -- needs a bunch of fixes and improvements.
Here is a first short list of issues:
1) Extend the set of supported (Scilab) internal data types, without which some bugs can't be fixed,
and improving or extending supported conversions won't be possible:
a) Missing vtype=Function, with property Macro|Builtin|?
b) Missing vtype=Polynomial, with property Real|Complex|?
c) Missing properties (in addition to Unknown), for existing vtypes:
Int: : "int8", "int16", "int32", "int64", "uint8", "uint16", "uint32", "uint64"
Handle: "Figure", "Axes" (as a first step. Presently, no property is defined and used).
String: String, Char (to distinguish "string" from 'char' (Matlab>2018). Octave has only char)
This is required before implementing the parsing of "strings" in concurrence to to 'chars'.
Boolean:
- The default property Real is misleading and should be replaced with Boolean (default).
- New property: Sparse. (Currently, Sparse boolean are not supported).
d) Void: this vtype defined in m2sci() is used nowhere in the whole m2sci. It should be removed.
BTW, are there any way to get a void elements in Matlab/Octave?
e) Type() and m2scideclare must be upgraded accordingly, to manage all new vtypes and properties.
2) Funcall(): the LHS argin should become optional. It must often be set to list(), that could become the default.
For some known function names frequently used in sci_funs conversion functions,
it could be automatically initialized accordingly.
3) Operation(): the out argout should become optional, with default = list() (it is very often the case).
4) Conversions TO FIX:
a) `a=1, b=2` is converted into `a = 1b = 2`, that yields a syntax error.
b) `['abc';'def']` : the result's property must become Char instead of Unknown.
c) The concatenation results are set to the type of the last operand, instead of applying concatenation precedence rules.
d) Function handles `@fun` were converted into a char 'fun' instead of into a function-handle object.
ishandle(@sin) is converted into type("sin")==9 instead of type(sin)==9.
e) `full(Boolean)` returns `full(bool2s(Boolean))`, instead of the same.
`full(BooleanSparse)` conversion yields an error in convert2double: Sparse boolean are never supported.
`full(String)` returns `mtlb_full(String)` instead of the same.
f) `mtlb_full()` is currently useless. It should be removed.
g) `sparse([true false])` conversion yields a `convert2double` error, instead of `sparse([%t,%f])`.
h) `isa('logical')` ignores sparse booleans. `isa('function_handle')` ignores builtins.
i) `isvector(Hypermat)` conversion id wrong (making isvector(rand(1,2,3)) returning %T).
j) `isreal` conversion wrongly uses eps=0: isreal(complex(1,0)) returns false with Matlab/Octave.
k) `[1 2]==1` result has property=Real, instead of Boolean.
m) `Cste(["abc" "de" ; "fg" "hij"])` initialized dims=list(2,10) instead of list(2,5).
5) Conversions TO IMPROVE:
a) 2*3*4*5 and 2*3/4 are converted into ((2*3)*4)*5 and (2*3)/4, instead of staying unchanged.
b) `a = true || false` is converted into `a = %t;if ~%t then a = %f;end`, instead of staying the same.
c) `a = true && false` is converted into `a = %f;if %t then a = %f;end;`, instead of staying the same.
d) `a = 1; b = 2` is converted into `a = 1;b = 2` without space separating instructions.
e) `for..,end;` is terminated with a parasitic ";" sticking to `end` (instruction2code).
6) Some conversions to complete:
a) isa(x, 'integer') and isa(x, 'float') are not converted.
b) isreal() is not implemented for Sparse, Boolean Sparse, Handle, Struct, Cell, and Function types.
7) MISC TO FIX:
a) In case of missing sci_function, the whole database of existing Matlab functions (and related toolboxes)
is loaded through mtlbtoolfun() each time that such a case is met. This is slow (1.12s x n).
If the database is loaded only once, at the first need, and then stored as global for direct
access, the speed becomes (0.3ms x n).
b) Codes for ||, and && operators are missing in sciparam()
8) Documentation
a) m2scideclare can be very helpful to check the vtype/property/size of a variable, for instance in tests.
This deserves to be documented.
b) The table of vtypes should be in the Type() page, instead of the m2scideclare one.
In addition, the list of supported properties should be given in the same table, for each vtype.
ERROR LOG:
----------
HOW TO REPRODUCE THE BUG:
-------------------------
OTHER INFORMATION:
------------------
Some additional issues would deserve to be processed, like
9) Reviewing + and - operations with []
10) Reviewing int#() functions conversion.
11) m2scideclare is too verbosy => gather discrepancy messages: There are presently as many messages as there are issues;
for instance one for distinct vtypes, another one for distinct properties, and may be a third one for distinct sizes.
=> As soon as there is at least one issue, a single message should be displayed.
Example: converting
d = [1 2]==1
%m2scideclare d|2 2|Double|Complex
yields
d = [1,2]==1"
// !! L.2: 'd' current size [1 2] <> [2 2] in m2scideclare: m2scideclare IGNORED.
// !! L.2: 'd' current type 'Boolean' <> 'Double' in m2scideclare: m2scideclare IGNORED.
// !! L.2: 'd' current property 'Boolean' <> 'Complex' in m2scideclare: m2scideclare IGNORED.
instead of something like
// !! L.2: m2scideclare 'd|2 2|Double|Complex' IGNORED: Can't force the current `d|1 2|Boolean|Boolean`.
#) ...