Thread Links Date Links
Thread Prev Thread Next Thread Index Date Prev Date Next Date Index

Re: textToIntevsal(s) and exceptions



Am 24.03.2015 um 16:59 schrieb Marco Nehmeier:
Am 24.03.2015 um 15:56 schrieb Vincent Lefevre:
On 2015-03-23 20:56:30 +0100, Marco Nehmeier wrote:
In my opinion we should avoid implicit conversion between bare and
decorated intervals as well as using inheritance...

Example.

two classes:
     interval
     decorated_interval (inherited from interval)

if we have a user function like

     interval foo(interval x)

which is only implemented for bare intervals.

In many languages a call of foo with a decorated interval x_d will
throw the the decoration d away because x_d is an object of
decorated_interval which is inherited from interval. Hence x_d is an
interval x.
I would see the inheritance in the other way round: a bare interval
can be regarded as a particular decorated interval, with the newDec
embedding. Therefore bare_interval would be inherited from
decorated_interval.


This is a mathematical or logical conclusion....
If we implement it this way, what is the benefit of using bare intervals
and
decorated intervals?

Additionally a decorated interval is defined in the standard as a pair of a
bare interval and a decoration.
Hence I think the most of the library developers will implement it like
my example
(if they use class inheritance).

Personally I have no problems if some one implements it with inheritance
(no matter in which direction)
or with implicit type conversion as long as the library can guarantee
the desired reliability of the standard.
This all is implementation specific ...
I only pointed out that there are some dangers if we recommend implicit
conversion or inheritance like Oliver.
With explicit type conversion we have clearly defined points in the
source code of the users where conversions
will be performed.

http://en.wikipedia.org/wiki/Circle-ellipse_problem

However, it is very much language and implementation specific.