[Scilab-users] Emulate Object Oriented Programming

Serge Steer serge.steer at inria.fr
Mon Nov 26 19:09:19 CET 2012


For safe mode you can use tlist with no field names. See the example in the attached file 

Serge Steer 

----- Mail original -----

> De: "Daniel Penalva" <dkajah at gmail.com>
> À: "International users mailing list for Scilab."
> <users at lists.scilab.org>
> Envoyé: Dimanche 25 Novembre 2012 23:04:56
> Objet: Re: [Scilab-users] Emulate Object Oriented Programming

> Hi,

> By safe you mean that the field is protected or private ? i dont know
> if it is possible in scilab nowadays ...

> [ ]s

> On Sun, Nov 25, 2012 at 7:28 PM, < michael.baudin at contrib.scilab.org
> > wrote:

> > Hi,
> 

> > I have a problem with the possibility of emulating OOP in Scilab
> > with
> 
> > tlists, that prevents me to have safe "set" methods.
> 
> > In the script in attachment, I created a human "class" with
> 
> > two fields: name (a scalar string) and weight (a scalar real).
> 

> > The problem is : how have a "set" method which is both simple and
> > safe ?
> 

> > Here is how this class works :
> 

> > bob=human_new()
> 

> > This is simple, but is unsafe:
> 

> > bob.name ="Bob"
> 
> > bob.weight=70
> 
> > bob.name =-12 // Oups !
> 

> > These statements are safe:
> 

> > bob=human_set(bob,"name"," Will")
> 
> > bob=human_set(bob,"weight",80)
> 

> > It is safe in the sense that the following statements produce an
> > error:
> 

> > bob=human_set(bob,"weight",- 12)
> 

> > The function "human_set" is safe but somewhat unconvenient to use.
> 

> > The question is :
> 

> > How to make so that bob.name ="Will" makes the code
> > bob=human_set(bob,"name"," Will") be executed ? Can overloading do
> > this ?
> 

> > Is the only possible way is at the C level with the sci_percent*
> > functions that Denizet wrote :
> 

> > http://gitweb.scilab.org/?p= scilab.git;a=blob;f=scilab/
> > modules/xml/sci_gateway/cpp/ sci_percent_XMLAttr_size.cpp; h=
> > 9d3b361bcbe6416e62f422dd448aa7 2d65f1fe4c;hb=HEAD
> 

> > for the XML module ?
> 

> > Best regards,
> 

> > Michaël
> 

> > _______________________________________________
> 
> > users mailing list
> 
> > users at lists.scilab.org
> 
> > http://lists.scilab.org/mailman/listinfo/users
> 

> --
> Democracia Digital Direta
> Carta:

> http://li7e.org/ddd2

> Des Carta coletiva aos ministerios
> http://rede.metareciclagem.org/blog/16-10-12/Des-Carta-da-Rede-Metareciclagem-para-o-Ministerio-da-Cultura-e-Outros-Ministerios-Tam

> AfroAmbiental eh sociedade em Axe e Diversidade

> http://afroambiental.org

> Daniel Penalva

> State related activity, currently:
> Phd - Physics in Institute for Theoretical Physics -
> http://www.ift.unesp.br/posgrad/ramais-alunos-pos.php

> Transparency portal(workflows):
> http://www.nightsc.com.br/aa/interface_v0.1.php *look for SUoU9
> user, or do ctrl+f and SUoU9*

> FLOSS and related ideas enthusiastic

> _______________________________________________
> users mailing list
> users at lists.scilab.org
> http://lists.scilab.org/mailman/listinfo/users
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.scilab.org/pipermail/users/attachments/20121126/d0c1b990/attachment.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: human.sci
Type: text/x-matlab
Size: 937 bytes
Desc: not available
URL: <https://lists.scilab.org/pipermail/users/attachments/20121126/d0c1b990/attachment.bin>


More information about the users mailing list