From: Maciej Sobczak on
On 16 Kwi, 22:20, "J-P. Rosen" <ro...(a)adalog.fr> wrote:
> Maciej Sobczak a écrit :> So which C++ language features exactly make it not strongly typed?
>
> 1) Lack of user-defined elementary types

This is addressed by:

http://www.msobczak.com/prog/typegen/

Alternative solutions involve templates or preprocessor or even hand-
written classes with appropriate operations - all of them are purely C+
+-based.

> 2) Type promotion

I don't see how type promotion violates the strong type safety.
In particular, type promotions are used in read-only operations (that
is, type is promoted when the value is read, not when it is written),
so they do not modify the state of the object that is subject to
promotion - as such, they do not subvert the type system in any way.

What about promoting integer values to Type'Base in arithmetic
operations?
Isn't it a form of type promotion?

--
Maciej Sobczak * http://www.inspirel.com

YAMI4 - Messaging Solution for Distributed Systems
http://www.inspirel.com/yami4
From: Pascal Obry on
Le 16/04/2010 19:24, Dmitry A. Kazakov a �crit :
> BTW, the Ada's OO kernel has this same design flaw. You can clone all
> types, but tagged:
>
> type Count is new Current; -- This is OK only if Current is not tagged!

type Count is new Current with null record;

Pascal.

--

--|------------------------------------------------------
--| Pascal Obry Team-Ada Member
--| 45, rue Gabriel Peri - 78114 Magny Les Hameaux FRANCE
--|------------------------------------------------------
--| http://www.obry.net - http://v2p.fr.eu.org
--| "The best way to travel is by means of imagination"
--|
--| gpg --keyserver keys.gnupg.net --recv-key F949BD3B

From: Dmitry A. Kazakov on
On Fri, 16 Apr 2010 22:53:04 +0200, Pascal Obry wrote:

> Le 16/04/2010 19:24, Dmitry A. Kazakov a �crit :
>> BTW, the Ada's OO kernel has this same design flaw. You can clone all
>> types, but tagged:
>>
>> type Count is new Current; -- This is OK only if Current is not tagged!
>
> type Count is new Current with null record;

That would not create an unrelated type, the class is same.

function "+" (Left : Current; Right : Current'Class) return Current;

X : Current;
Y : Count;
begin
X := X + Y; -- No type error

--
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de
From: J-P. Rosen on
Maciej Sobczak a �crit :
> On 16 Kwi, 22:20, "J-P. Rosen" <ro...(a)adalog.fr> wrote:
>> Maciej Sobczak a �crit :> So which C++ language features exactly make it not strongly typed?
>>
>> 1) Lack of user-defined elementary types
>
> This is addressed by:
>
> http://www.msobczak.com/prog/typegen/
This shows that an educated Ada programmer, well aware of the issues of
strong typing, can mimmic the same behaviour in C++. But how many C++
programmers use that?

>> 2) Type promotion
>
> I don't see how type promotion violates the strong type safety.
Type promotion is based on the underlying representation, not on
abstract types. And it is a form of automatic type case - which is
always a bad idea IMHO.

Note that T'Base is the same type as T, so there is no issue here.
--
---------------------------------------------------------
J-P. Rosen (rosen(a)adalog.fr)
Visit Adalog's web site at http://www.adalog.fr
From: Dmitry A. Kazakov on
On Sat, 17 Apr 2010 07:25:25 +0200, J-P. Rosen wrote:

> Note that T'Base is the same type as T, so there is no issue here.

But it is not all same. The behavior of T'Base may differ, so it might be
unsafe to use one as an equivalent of another in certain contexts
(substitutability violation).

--
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de