Leslaw Bieniasz said:
Are there any scientific publications about the
"square-rectangle problem" (also known as the "circle-ellipse
problem")
This has nothing to do whatsoever specifically with C++.
It has been solved by me some years ago - I don't know if
anyone else has published this solution, but I guess so:
This pseudoproblem only comes from the lack of distinction
between a /value/ and a /store/ (i.e., a typed region of storage).
Every square value is a rectangle value.
Every rectangle store is a square store.
(If you remove »value« and »store« from the sentences
above, you will get two contradicting statements.)
These four lines from above are all to be written about
this pseudo-problem. It is this shallow. It does not even
have to do with object-oriented programming, but with
programming in general as soon as typed stores are used.
Most articles on this »problem« do not make this solution clear,
yes, it seems as most authors really are not aware of it
and therefore are a »part of the problem«, not of the solution.
For another example, assume, x e {0,1} and y e {0,1,2,3}
(e = »element of«).
Then, every x is a y, that is x e {0,1,2,3} is always true.
That is,
every x-value is a y-value.
Now, assume, x* s {0,1} and y* s {0,1,2,3}
(s = »is able to store a value from the set ...«).
Then, every y* is an x*, that is y* s {0,1} is always true.
That is,
every x-store is a y-store.
Thus, the general rule is:
Whenever a value set U is a subset of a value set S, then
every U value is an S value, and every S store is a U store.
In C++, an immutable (const) object representing a square or
a rectangle is a »value« in the sense used above, while a
mutable (non-const) object able to store a square value or a
rectangle value is a »store« in the sense used above.
There is another place in C++, where it might have to
be observed (I do not know how this usually is treated in C++):
When U is a subtype of T, then vector<U> will usually /not/ be
a subtype of vector<T>. This is so, because a vector of a type
is not a value of this type, but a store for values of this type.
Citation for this publication:
Stefan Ram, On the Square-Rectangle Problem, Usenet-post
<
[email protected]>, 2010.