Steven Watanabe | 1 Apr 2008 04:17
Picon

Re: [mp_math] a multi precision signed integer library

AMDG

Maarten Kronenburg wrote:
> In my opinion an unsigned integer is a, works like a and can be substituted
> as an integer, and so is a modular integer, and as far as I'm concerned also
> an allocated integer. This is why I choose for derivation, and then with the
> base pointer to derived object (as quoted above) to runtime polymorphism.
>   

I strongly disagree.

1)  An unsigned integer only works like an integer for non-mutating
operations.  If clients take parameters of const integer&, sure, 
unsigned_integer
will work fine in this context.  Treating non-const integers 
polymorphically is a very bad
idea, though.  Code that does so has to be very carefully designed to 
make sure that
it can handle all the combinations.  If you have to use inheritance, 
make both integer and
unsigned_integer inherit from a common base.

2) I would expect an integer class to be a value object. virtual 
functions don't play
well with value objects, because to prevent slicing, everything has to 
be held by
pointer.

3) unsigned_integer + unsigned_integer should return an 
unsigned_integer.  There
is no way for the result to be negative.  This is even more glaring for 
modular_integer

> And in my opinion an integer is not a container, so I see no reason to use
> templates.
>   

???

In Christ,
Steven Watanabe

_______________________________________________
Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost


Gmane