BUG DESCRIPTION:
----------------
In Scilab 5, it was possible to test actually passed input arguments
with isdef(itsname,"l"), and then set default values when appropriated.
It is a far more robust way to set defaults than just testing argn(2).
This is no longer the case with Scilab 6.0: isdef(itsname,"l") now
ALWAYS returns %T. This is a problem for several reasons:
* This sets some back-compatibility issues
* This breaks the homogeneity with respect to varargins processing.
* This compels testing the type() against 0, to see if a value has
been actually passed. It is more complicated.
If this change is intentional, the rationale for it would be welcome.
// Let
function test(a, varargin)
b = varargin(1);
if isdef("a","l") then
disp("arg#1 is defined")
printf("type(a)=%d typeof(a)=%s\n", type(a),typeof(a));
end
if isdef("b","l") then
disp("arg#2 is defined")
printf("type(b)=%d typeof(b)=%s\n", type(b),typeof(b));
end
endfunction
// ----------------
Scilab 5.5.2
============
-->test(,2) // OK
arg#2 is defined
type(b)=1 typeof(b)=constant
-->test(,,3) // OK
-->
Scilab 6.0.0
============
--> test(,2)
arg#1 is defined // NOK : this REPORT
type(a)=0 typeof(a)=void
arg#2 is defined
type(b)=1 typeof(b)=constant
--> test(,,3)
arg#1 is defined // NOK
type(a)=0 typeof(a)=void
ERROR LOG:
----------
HOW TO REPRODUCE THE BUG:
-------------------------
function test(a, varargin)
b = varargin(1);
if isdef("a","l") then
disp("arg#1 is defined")
printf("type(a)=%d typeof(a)=%s\n", type(a),typeof(a));
end
if isdef("b","l") then
disp("arg#2 is defined")
printf("type(b)=%d typeof(b)=%s\n", type(b),typeof(b));
end
endfunction
test(,2)
test(,,3)
OTHER INFORMATION:
------------------