[Scilab-users] strange %h_set overloading

classic Classic list List threaded Threaded
2 messages Options
mottelet mottelet
Reply | Threaded
Open this post in threaded view
|

[Scilab-users] strange %h_set overloading

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" ?

My other question/remark is about the naming convention of built-in
functions like "set". When macros do exist wit the same name but in
different libraries,  the library name used as a prefix plays the role
of a namespace and allows to disambiguate calls: e.g."graphicslib.plot"
vs "plolib.plot". However, there is no namespace for built-in functions.

The reason for these questions is that I am currently re-engineering the
plotlib and need a smooth mechanism to emulate new properties/fields for
*native* Scilab handles.

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

_______________________________________________
users mailing list
[hidden email]
http://lists.scilab.org/mailman/listinfo/users
mottelet mottelet
Reply | Threaded
Open this post in threaded view
|

Re: strange %h_set overloading

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

_______________________________________________
users mailing list
[hidden email]
http://lists.scilab.org/mailman/listinfo/users