[Scilab-Dev] SEP: Object oriented programming under scilab
ycollet at freesurf.fr
ycollet at freesurf.fr
Fri Oct 3 15:01:27 CEST 2008
Thanks for these infos.
And what about adding the following rule in the parser:
if typeof(x) == 'constant' then call the 'naked' function (without %....)
else call %.....
For OO programming, we just need to overload operators and functions
for user defined type ...
YC
Serge Steer <Serge.Steer at scilab.org> a écrit :
> 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
>
>
>
--
Transmis via le Webmail FreeSurf: http://www.freesurf.fr
More information about the dev
mailing list