# [Scilab-users] How to overload "double" function ?

5 messages
Open this post in threaded view
|

## [Scilab-users] How to overload "double" function ?

 Hi, I want to overload some usual scilab functions, I made it for abs and sign but strangely it doesn't work for double ! Let's take an example , I want to extend sign and double for polynomials  : --> X=poly(0,"x"); // a polynomial --> sign(X) dans la fonction native        sign Fonction non définie pour les types fournis.   vérifier les arguments ou définir la fonction %p_sign pour la surcharge. --> double(X) double : Types erronés des arguments d'entrée : entiers, booléens ou réels attendus. so I define overloading for the two functions and "p" type :  function y=%p_sign(x)      y="OK"  endfunction  function y=%p_double(x)     y="OK"  endfunction Now I can call sign on a polynomial, but this doesn't work for double --> sign(X)  ans  =  OK --> double(X) double : Types erronés des arguments d'entrée : entiers, booléens ou réels attendus. How can I do this for double ? If not why this doesn't work ? Both sign and double are "fptr" type , I thought that scilab-6 doesn't make difference between function and fptr any more . Philippe _______________________________________________ users mailing list [hidden email] http://lists.scilab.org/mailman/listinfo/users
Open this post in threaded view
|

## Re: How to overload "double" function ?

 Hello Philippe, The overloading mechanism is not systematic. It is implemented (or not) function per function. It is currently proposed for some of them, but not all of them. If you need it for double(), you shall post a wish on Bugzilla. Best regards Samuel PS: for instance, iconvert(p,0) makes the same as double(), and is overloadable: --> iconvert(%z,0) in builtin                iconvert Function not defined for given argument type(s),   check arguments or define function %p_iconvert for overloading. Le 21/08/2018 à 17:11, philippe a écrit : Hi, I want to overload some usual scilab functions, I made it for abs and sign but strangely it doesn't work for double ! Let's take an example , I want to extend sign and double for polynomials : --> X=poly(0,"x"); // a polynomial --> sign(X) dans la fonction native sign Fonction non définie pour les types fournis. vérifier les arguments ou définir la fonction %p_sign pour la surcharge. --> double(X) double : Types erronés des arguments d'entrée : entiers, booléens ou réels attendus. so I define overloading for the two functions and "p" type : function y=%p_sign(x) y="OK" endfunction function y=%p_double(x) y="OK" endfunction Now I can call sign on a polynomial, but this doesn't work for double --> sign(X) ans = OK --> double(X) double : Types erronés des arguments d'entrée : entiers, booléens ou réels attendus. How can I do this for double ? If not why this doesn't work ? Both sign and double are "fptr" type , I thought that scilab-6 doesn't make difference between function and fptr any more . Philippe _______________________________________________ users mailing list [hidden email] http://lists.scilab.org/mailman/listinfo/users _______________________________________________ users mailing list [hidden email] http://lists.scilab.org/mailman/listinfo/users
Open this post in threaded view
|

## Re: How to overload "double" function ?

 Hi Samuel, Le 22/08/2018 à 11:12, Samuel Gougeon a écrit : > > The overloading mechanism is not systematic. It is implemented (or not) > function per function. > It is currently proposed for some of them, but not all of them. > If you need it for double(), you shall post a wish on Bugzilla. Thanks Samuel! In fact, I've already overloaded iconvert but I did not remembered it! Since the error message refers to "double" it is not easy to remember the correct way for overloading. > > PS: for instance, iconvert(p,0) makes the same as double(), and is > overloadable:  That's the problem : it was true in scilab-5  but iconvert seems no longer overload double in scilab-6. See below : --> function y=%p_iconvert(x,itype)   >     y="OK"   >  endfunction -->  X=poly(0,"x")  X  =    x -->  double(X) double : Types erronés des arguments d'entrée : entiers, booléens ou réels attendus. -->  iconvert(X,0)  ans  =  OK Sincerely yours, Philippe _______________________________________________ users mailing list [hidden email] http://lists.scilab.org/mailman/listinfo/users