[Scilab-Dev] Object Orientation

Clément David clement.david at scilab-enterprises.com
Mon Feb 20 10:36:33 CET 2017


Hi Amanda,

> I'm searching for inspiration in Struct DataType. I believe I can use it as a base.
> 
> So, I need to ask.
> 
> What prevents me to insert a function inside a struct ?

Nothing :) ! From the user point of view, a function can be passed by value and called later.

> Because of what i understood, in the Scilab's  core the  struct datatype uses a class named
> SingleStruct , which in turn,  uses the class InternalType to handle the struct's content.
> 
> And the class InternalType can handle functions.
> 
> If someone has a better idea I would like to listen.

Some times ago, a detailed analysis has been done to implement (aka emulate as this is not native)
an object oriented paradigm. Like in Javascript or Python, the user should just follow some coding
conventions to define the object and pass it around. However I prefer using an mlist() rather than a
struct() to avoid multi-dimensional issues ; a struct() have multiple dimensions defined by :

a.b = 1;
a // 1x1 struct
a(4,5).b = 2; // resize a
a // 4x5 struct with empty "b" values

Do not hesitate to contribute and edit the wiki if you need / look for more tests !

[1]: https://wiki.scilab.org/Emulate%20Object%20Oriented%20in%20Scilab

Thanks,

--
Clément



More information about the dev mailing list