[Gambas-devel] Proper way to the current object
Benoît Minisini
gambas at ...1...
Sun Feb 12 20:32:20 CET 2012
Le 11/02/2012 23:07, Randall Morgan a écrit :
> Hi Benoit,
>
> 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.
Even if only Juergen asks for GSL, you are actually making the component
for every possible user.
> 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.
No. By systematically creating a new object, you are doing something
that is not always needed, and so you lower the processing speed.
So I told you not to create this object, and to add a Copy() method.
For complex numbers, copying is not a heavy process, but think about
bigger objects (matrix, polynomial...), where a systematic copy will be
a problem.
> Most calculations will require the result to
> be passed to another object.
What is the relation between not systematically intenally copying object
and passing a result?
> Now I am still learning about all of this
> so it could change...
>
> 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.
>
> 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.
I think this is a bad idea, because:
1) People expect the behaviour of the GSL library.
2) Using GSL types directly makes code cleaner and shorter.
Later, when you will have a working component and more experience, you
will be able to make complex numbers more complex. :-)
Regards,
--
Benoît Minisini
More information about the Devel
mailing list