Function return values in GMP? (James Wheaton)
Hans Aberg
haberg at math.su.se
Thu Mar 2 19:35:04 CET 2006
On 2 Mar 2006, at 17:08, Décio Luiz Gazzoni Filho wrote:
> On Mar 2, 2006, at 10:21 AM, Hans Aberg wrote:
>
>> On 2 Mar 2006, at 00:33, Décio Luiz Gazzoni Filho wrote:
>>>
>>> Actually that is a well known problem with operator overloading
>>> in C+
>>> + and which has been solved (though not 100% satisfactorily) using
>>> the technique of `expression templates', which by the way is
>>> implemented in the C++ wrapper for GMP.
>>
>> This does not solve the problem, because templates just provides a
>> static (compile time only) programming
>
> Expression templates solve the problem for 99.9% of users.
Please back this up with facts. :-)
> Now certainly there are the hardcore abstract OO types who want to
> do everything dynamically. Still, I don't see why it'd be
> impossible to use expression templates and dynamic typing
> simultaneously.
It's only that it's wholly unnecessary. Once one starts with dynamoc
programing there is littyle use and little point with templates.
> Meaning you could write code like this:
>
> ----------
> base_t* x = new derived_t;
> base_t* y = new derived_t;
>
> *x = *x + *y;
> ----------
>
> and get the correct behavior without temporary generation.
And how do you get it into polymorphic class hierarchy? And when
done, how does the virtual function class interface look like?
> Of course, it'd require some modifications from, say, the C++ GMP
> wrapper in order to generalize it, but it's possible. Now writing
> code where the expressions themselves are generated at runtime, say
> a calculator parsing user input, might indeed not work -- I haven't
> thought enough about it to be sure.
So it seems. :-) Why don't you try it? :-)
Hans Aberg
More information about the gmp-discuss
mailing list