overload user-defined functions
overload(funnam [,type])
overload()
overload(table_of_overloaded_fun)
name of a user-defined function
an optional vector (1 by n) of strings containing the types already managed by the function (see overloading for type codes)
a matrix (n by 2) of strings containing in the first column the name of functions which manage a specific type and in the second column the name of a real function.
This function gives the possibility to overload user-defined functions.
The overloaded function must exist in memory or in a accessible file.
For example, the call overload(funnam,['s','c'])
makes the copy %s_fun=fun
, creates an entry %c_fun
in table which points to '%s_fun'
, clears fun
and creates an entry point fun
in the dynamic library. After that, the call of fun(arg1,...)
will be transformed in %<type_of_arg1>_fun(arg1,...)
.
Take care that only 98 functions can be overloaded by the toolbox.
//define a fun inc for constant (type 's'), //polynomial ('p') or boolean ('b') //but not for string ('c') deff('y=inc(x)','y=x+1') //define a function %c_inc which //deals the string type deff('y=%c_inc(x)','y=code2str(str2code(x)+1)') //overload the function inc and preserve //the types 's', 'p' and 'b' overload('inc',['s' 'p' 'b']) //now we can use inc with constant, //polynomial or string inc(2),inc(1+%s+%s^2),inc(%t) inc('abcdef') //to see types managed by %s_inc a=overload() //you can remove 'p' type a(2,:)=[],overload(a) inc(%s) | ![]() | ![]() |