Hi Benoit,<div><br></div><div>The reason for creating a new object containing the result was requested by Juergen. He's the math wizard her, I am just trying to make the GSL work in Gambas for him. However, I do feel after thinking about it that if most methods save the result in the current method you limit the usuability of the library. Most calculations will require the result to be passed to another object. Now I am still learning about all of this so it could change... </div>

<div><br></div><div>The code in the current files is nowhere near final and is there for experimentation as for me that is the best way to learn. </div><div><br></div><div>The reason for creating  a separate complex number is because this structure may change to include both accuracy information and may or may not be modified to include information on whether the number is Cartesian or polar. Both of which could also be included in a single object. However, when I move to vectors and matrices these structures will need to be separate structures and at the moment this gives me a way to experiment with having a separate structure.</div>

<div><br><div class="gmail_quote">2012/2/11 Benoît Minisini <span dir="ltr"><<a href="mailto:gambas@...1...">gambas@...1...</a>></span><br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">

Le 11/02/2012 20:24, Benoît Minisini a écrit :<br>
<div class="im">> Le 11/02/2012 20:23, Benoît Minisini a écrit :<br>
>> Le 09/02/2012 15:56, Randall Morgan a écrit :<br>
>>> Hi Benoit,<br>
>>><br>
>>> I am a bit perplexed. I have some code that works and some that<br>
>>> doesn't...<br>
>><br>
>> If a method or a property returns a "GslComplex", then its signature<br>
>> must use "GslComplex;" (or just "GslComplex" in a return value<br>
>> signature). Do not use "o", this is an anonymous object that you should<br>
>> use only if the method or property returns any object.<br>
>><br>
>> And when you receive an object reference through GB_OBJECT, you must use<br>
>> GB.CheckObject() to check it (to ensure it is not null).<br>
>><br>
>> Regards,<br>
>><br>
><br>
> Another point: Use NULL and not a void string for methods returning<br>
> nothing, and/or having no arguments.<br>
><br>
<br>
</div>Other points again.<br>
<br>
1) Why didn't you use gsl_complex directly in the GSLCOMPLEX structure?<br>
<br>
2) You chose to create a new Complex each time you act on it.<br>
<br>
Maybe this is not a good idea (for performance reasons). I think you<br>
should better:<br>
<br>
- Act on the current object without creating a new one, and return it<br>
anyway.<br>
<br>
- Add a Copy() method to copy a complex number when this is really needed.<br>
<br>
So here is the "not-tested" result:<br>
<br>
--------------------------------------------------------------------<br>
<br>
typedef<br>
   struct {<br>
     GB_BASE ob;<br>
     gsl_complex c;<br>
     }<br>
   GSLCOMPLEX;<br>
<br>
BEGIN_METHOD(GslComplex_Add, GB_OBJECT x)<br>
<br>
   GSLCOMPLEX *x = VARG(x);<br>
<br>
   if (GB.CheckObject(x))<br>
     return;<br>
<br>
   THIS->c = gsl_complex_add(THIS->c, x->c);<br>
   GB.ReturnObject(THIS); // GB.ReturnXXXX() methods return nothing!<br>
<br>
END_METHOD<br>
<br>
--------------------------------------------------------------------<br>
<br>
The code is simpler, isn't it?<br>
<div class="HOEnZb"><div class="h5"><br>
--<br>
Benoît Minisini<br>
<br>
------------------------------------------------------------------------------<br>
Virtualization & Cloud Management Using Capacity Planning<br>
Cloud computing makes use of virtualization - but cloud computing<br>
also focuses on allowing computing to be delivered as a service.<br>
<a href="http://www.accelacomm.com/jaw/sfnl/114/51521223/" target="_blank">http://www.accelacomm.com/jaw/sfnl/114/51521223/</a><br>
_______________________________________________<br>
Gambas-devel mailing list<br>
<a href="mailto:Gambas-devel@lists.sourceforge.net">Gambas-devel@...595...urceforge.net</a><br>
<a href="https://lists.sourceforge.net/lists/listinfo/gambas-devel" target="_blank">https://lists.sourceforge.net/lists/listinfo/gambas-devel</a><br>
</div></div></blockquote></div><br><br clear="all"><div><br></div>-- <br>If you ask me if it can be done. The answer is YES, it can always be done. The correct questions however are... What will it cost, and how long will it take?<br>


</div>