Function return values in GMP? (James Wheaton)

Daniel J Farrell daniel.farrell at imperial.ac.uk
Wed Mar 1 23:53:56 CET 2006


Nicely put Jim.

This is exactly what I have been doing with cocoa and objective-c.  
Like you suggest all arithmetic ops. need to make use of temp  
variables which need to be created and destroyed to avoid memory  
leaks. e.g.

A = B + C

means that a temp object containing the value of B+C need to be  
created inside you method/function, passed into the memory space for  
A, then destroyed.

A =+ B

is different because you can get away with using A as the temp  
because your just summing into it every time.

It's stuff like this that isn't apparent until you actually sit down  
an write the code. Hence that's why the result gmp variable is passed  
as a function argument - to by pass the memory management issues of  
temp variables.

Daniel.


There is a C++ wrapper in existence right?


On 28 Feb 2006, at 02:32, Jim White wrote:


>
> I agree with the other responses.  GMP is a library,
> not a package.  It's primary concern is the provision
> of arithmetic services, on which applications or
> packages can be based.
>
> Issues such as temp variable management,
> instantiation, etc, tend to have different optimal
> strategies in different application contexts, so GMP
> sensibly keeps the interface simple, and leaves most
> non-arithmetic issues to you the programmer.
>
> The key to customising your particular GMP application
> environment to your needs is to write your own wrapper
> functions, ie. develop your own interface library.
>
> This can be done incrementally, you don't need to
> write a complete package, just add appropriate
> functionality piece by piece to make your application
> programming easier, and eventually you'll get the
> interface library to a point whereby your application
> programs don't need to make any direct calls to GMP at
> all.
>
>
> Jim White
> ANU, Canberra
> _______________________________________________
> gmp-discuss mailing list
> gmp-discuss at swox.com
> https://gmplib.org/mailman/listinfo/gmp-discuss


More information about the gmp-discuss mailing list