[Scilab-Dev] SEP: Object oriented programming under scilab
Serge Steer
Serge.Steer at scilab.org
Fri Oct 3 13:52:07 CEST 2008
Sylvestre Ledru a écrit :
>
> In the meantime, the point "have the possibility to overload macros"
> should be a specific SEP which could be address in Scilab 6.
>
>
As there is no typing for the input argument of a macro automatic
overloading is difficult if it is not explicitely handled in the macro
code as in the example below:
function y=foo(x)
if typeof(x)<>'constant' then
execstr('y= %'+typeof(x)+'_foo(x)')
else
y=x^2+1
endfunction
If the function to be overaloaded is stored in a library, there is an
other solution
Example: let define atanh for integer type
-->atanh(int32(2))
!--error 10000
atanh: Mauvais type pour l'argument d'entrée n° 1: Matrice réelle ou
complexe attendu.
-->function y=atanh(x)
elementary_functionlib.atanh //recall the default atanh
if typeof(x)=="int32" then
y=atanh(double(x))
else
y=atanh(x)
end
endfunction
-->atanh(int32(2))
ans =
0.5493061 - 1.5707963i
More information about the dev
mailing list