[Scilab-users] Multiple files of functions with the same name
Samuel Gougeon
sgougeon at free.fr
Thu Jul 3 09:14:02 CEST 2014
Hello,
Le 03/07/2014 04:14, Llelan D. a écrit :
> A common task I've coded is to run multiple implementations of the
> same function head-to-head to profile their effectiveness. An example
> would be a competition in which each of two implementations provide a
> response for each match. The usual way in other interpreted languages
> is to have the implementers write a source file implementing the same
> function prototype (same name, arguments, and return type). You load
> each one in their own namespace and run each for each match.
>
> Is there a way to load the functions in two .sci files so that the
> second does not clobber the first.
Let say that you have 2 functions written in Scilab language, with the
same name "fun(..)" and same or distinct profiles (possible calling
sequences). If each one is declared in a specific library -- say lib1
and lib2 --, then you can call each one separately: lib1.fun(...) will
call the first implementation, and lib2.fun(..) the second one ; etc. I
think -- but this must be checked -- that after calling lib1.fun(..),
this implementation will be loaded in memory, replacing any other
previous loaded implementation of fun(..). So, if then you call simply
fun(..), still the lib1 implementation will be run.
HTH
Samuel
More information about the users
mailing list