[Scilab-users] strange %h_set overloading

Stéphane Mottelet stephane.mottelet at utc.fr
Thu Mar 1 19:47:15 CET 2018


OK, answering to myself...

Le 01/03/2018 à 09:29, Stéphane Mottelet a écrit :
> Hello,
>
> I have a question concerning the overloading function %h_set and 
> concerning overloading mechanism in general.
>
> Here is an example where the original %h_set is redefined in order to 
> display "in %h_set" when it is called:
>
> function hdl=%h_set(varargin)
>     disp("in %h_set")
>     if (size(varargin) == 3)
>         hdl = varargin(1)
>         str = varargin(2)
>         val = varargin(3)
>         for i=1:size(hdl,"*")
>             set(hdl(i),str,val)
>         end,
>     elseif (size(varargin) == 2)
>         str = varargin(1)
>         val = varargin(2)
>         hdl=[]
>         set(str,val)
>     end,
> endfunction
>
> set(gcf(),'tag','foo');
> set([gcf(),gcf()],'tag','foo');
>
> --> set(gcf(),'tag','foo');
>
> --> set([gcf(),gcf()],'tag','foo');
>
>  in %h_set
>
> %h_set is not called wen a 1x1 handle is used, but only when a vector 
> of more than 2 handles is used. I suppose this mechanism is 
> implemented i the built-in "set" ?
>
ok, seen in the source (modules/graphics/sci_gateway/c/sci_set.c)

S.


-- 
Stéphane Mottelet
Ingénieur de recherche
EA 4297 Transformations Intégrées de la Matière Renouvelable
Département Génie des Procédés Industriels
Sorbonne Universités - Université de Technologie de Compiègne
CS 60319, 60203 Compiègne cedex
Tel : +33(0)344234688
http://www.utc.fr/~mottelet




More information about the users mailing list