Hi,<br><br>By safe you mean that the field is protected or private ? i dont know if it is possible in scilab nowadays ...<br><br>[ ]s <br><div class="gmail_extra"><br><br><div class="gmail_quote">On Sun, Nov 25, 2012 at 7:28 PM, <span dir="ltr"><<a href="mailto:michael.baudin@contrib.scilab.org" target="_blank">michael.baudin@contrib.scilab.org</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi,<br>
<br>
I have a problem with the possibility of emulating OOP in Scilab with<br>
tlists, that prevents me to have safe "set" methods.<br>
In the script in attachment, I created a human "class" with<br>
two fields: name (a scalar string) and weight (a scalar real).<br>
<br>
The problem is : how have a "set" method which is both simple and safe ?<br>
<br>
Here is how this class works :<br>
<br>
bob=human_new()<br>
<br>
This is simple, but is unsafe:<br>
<br>
<a href="http://bob.name" target="_blank">bob.name</a>="Bob"<br>
bob.weight=70<br>
<a href="http://bob.name" target="_blank">bob.name</a>=-12 // Oups !<br>
<br>
These statements are safe:<br>
<br>
bob=human_set(bob,"name","<u></u>Will")<br>
bob=human_set(bob,"weight",80)<br>
<br>
It is safe in the sense that the following statements produce an error:<br>
<br>
bob=human_set(bob,"weight",-<u></u>12)<br>
<br>
The function "human_set" is safe but somewhat unconvenient to use.<br>
<br>
The question is :<br>
<br>
How to make so that <a href="http://bob.name" target="_blank">bob.name</a>="Will" makes the code bob=human_set(bob,"name","<u></u>Will") be executed ? Can overloading do this ?<br>
<br>
Is the only possible way is at the C level with the sci_percent* functions that Denizet wrote :<br>
<br>
<a href="http://gitweb.scilab.org/?p=scilab.git;a=blob;f=scilab/modules/xml/sci_gateway/cpp/sci_percent_XMLAttr_size.cpp;h=9d3b361bcbe6416e62f422dd448aa72d65f1fe4c;hb=HEAD" target="_blank">http://gitweb.scilab.org/?p=<u></u>scilab.git;a=blob;f=scilab/<u></u>modules/xml/sci_gateway/cpp/<u></u>sci_percent_XMLAttr_size.cpp;<u></u>h=<u></u>9d3b361bcbe6416e62f422dd448aa7<u></u>2d65f1fe4c;hb=HEAD</a><br>
<br>
for the XML module ?<br>
<br>
Best regards,<br>
<br>
Michaël<br>
<br>
<br>_______________________________________________<br>
users mailing list<br>
<a href="mailto:users@lists.scilab.org">users@lists.scilab.org</a><br>
<a href="http://lists.scilab.org/mailman/listinfo/users" target="_blank">http://lists.scilab.org/mailman/listinfo/users</a><br>
<br></blockquote></div><br><br clear="all"><br>-- <br><b>Democracia Digital Direta<br>Carta:<br><br></b><a href="http://li7e.org/ddd2" target="_blank">http://li7e.org/ddd2</a><br><br><b>Des Carta coletiva aos ministerios<br>
</b><a href="http://rede.metareciclagem.org/blog/16-10-12/Des-Carta-da-Rede-Metareciclagem-para-o-Ministerio-da-Cultura-e-Outros-Ministerios-Tam" target="_blank">http://rede.metareciclagem.org/blog/16-10-12/Des-Carta-da-Rede-Metareciclagem-para-o-Ministerio-da-Cultura-e-Outros-Ministerios-Tam</a><b><br>
</b><br><b>AfroAmbiental eh sociedade em Axe e Diversidade</b><br><br><a href="http://afroambiental.org" target="_blank">http://afroambiental.org</a><br><br>Daniel Penalva<br><br>State related activity, currently:<br>Phd - Physics in Institute for Theoretical Physics - <a href="http://www.ift.unesp.br/posgrad/ramais-alunos-pos.php" target="_blank">http://www.ift.unesp.br/posgrad/ramais-alunos-pos.php</a><br>
<br>Transparency portal(workflows): <a href="http://www.nightsc.com.br/aa/interface_v0.1.php" target="_blank">http://www.nightsc.com.br/aa/interface_v0.1.php</a> *look for SUoU9 user, or do ctrl+f and SUoU9*<br><br>FLOSS and related ideas enthusiastic<br>
<br>
</div>