BUG DESCRIPTION:
----------------
Please upgrade deff():
1) The created function can't be returned as output argument. This prevents using deff() on the fly
as in
actualName = deff("r = anyFakeName(x,y)", "r = x.*(x-y)");
or in
L = list("Abc", deff("r = anyFakeName(in1, in2)", "r=in1+in2"), %f)
or in
function r = test(txt, x, theFunc)
r = x + theFunc(txt)
endfunction
test(rand(2,3), 0.7, deff("r = anyFakeName(M) sum(size(M).^2)"))
2) The current implementation requires to provide the function headline and body separately.
This requirement is a bit strange. Providing both in a single input argument should become possible,
as in
source = ["[a,b] = test(x)" ; "a = x.^2" ; "b = (x-3).^3"];
deff(source)
3) For a trivial function body, a one-string definition should be accepted, as in
deff("[a,b] = test(x) a = x.^2; b = 2*x")
and so allows a console-oriented syntax
deff "[a,b] = test(x) a = x.^2; b = 2*x"
4) In the case of a one-string definition of a function with a single output,
a simplification should even be allowed, as in
deff "r = test(x) (x-1).^2"
instead of more completely
deff "r = test(x) r = (x-1).^2"
5) When the defined function is assigned as in cases listed in 1), the literal name "anyFakeName"
is fake. In this case, the "@" character should be allowed as function pseudo-name, as in
myFunc = deff("r = @(x) (x-1).^2")
instead of
myFunc = deff("r = anyFakeName(x) (x-1).^2")
ERRORS MESSAGES
---------------
--> myFunc = deff("r = anyFakeName(in1, in2)", "r=in1+in2")
Wrong number of output arguments.
--> L = list("Abc", deff("r = anyFakeName(in1, in2)", "r=in1+in2"), %f)
L =
L(1)
"Abc"
L(2) <<<<<< The function should be here, and the list should have 3 elements.
F
--> source = ["[a,b] = test(x)" ; "a = x.^2" ; "b = (x-3).^3"];
--> deff(source)
at line 3 of function deff ( SCI\modules\functions\macros\deff.sci line 14 )
deff: Wrong number of input arguments: 2 expected.
--> deff("[a,b] = test(x) a = x.^2; b = 2*x")
at line 3 of function deff ( SCI\modules\functions\macros\deff.sci line 15 )
deff: Wrong number of input arguments: 2 expected.
HOW TO REPRODUCE THE BUG:
-------------------------
myFunc = deff("r = anyFakeName(in1, in2)", "r=in1+in2")
L = list("Abc", deff("r = anyFakeName(in1, in2)", "r=in1+in2"), %f)
source = ["[a,b] = test(x)" ; "a = x.^2" ; "b = (x-3).^3"];
deff(source)
OTHER INFORMATION:
------------------
* Feature 1) required to create and use anonymous functions,
@ http://bugzilla.scilab.org/show_bug.cgi?id=9964#add_comment
* deff() could then replace the createfun() internal function (bug 9964 => WONT + removing createfun())