comp.lang.ada
 help / color / mirror / Atom feed
From: Maciej Sobczak <see.my.homepage@gmail.com>
Subject: Re: A new notion: stronglly-typed-by-user language
Date: Mon, 19 Apr 2010 01:46:51 -0700 (PDT)
Date: 2010-04-19T01:46:51-07:00	[thread overview]
Message-ID: <a6c37673-e026-4315-91c9-f2ea61c089bd@i40g2000yqd.googlegroups.com> (raw)
In-Reply-To: 52b7b2ba-ca54-42f4-abd7-41082a49a333@e7g2000yqf.googlegroups.com

On 18 Kwi, 22:38, Gautier write-only <gautier_niou...@hotmail.com>
wrote:

> - in C++, is it possible to do arithmetic with the (or a) boolean
> type, or convert silently from/to integer ?

Yes, bool is promoted to int (false->0, true->1) when used in mixed
context.

> - in C++, is it possible to assign a value of a type enum1 to a
> variable of type enum2,

No. Enums are distinct types and assignment between them requires
explicit conversion.

> or is it possible to do any mix or arithmetic
> without something like enum1'Pos ?

Enums can be promoted to int, so you can do "arithmetic" on them.
But you would not be able to silently assign the result back to enum,
as conversion from int (the result of "arithmetic") would have to be
explicit.

That is, you cannot use these tricks to silently subvert the type
system to mess the value of the enumeration type.

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

YAMI4 - Messaging Solution for Distributed Systems
http://www.inspirel.com/yami4



      reply	other threads:[~2010-04-19  8:46 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-04-15  8:59 A new notion: stronglly-typed-by-user language J-P. Rosen
2010-04-15  9:19 ` Martin Krischik
2010-04-16  0:22   ` BrianG
2010-04-16  6:26     ` Martin Krischik
2010-04-15  9:59 ` Dmitry A. Kazakov
2010-04-15 10:49 ` Georg Bauhaus
2010-04-15 21:31 ` Maciej Sobczak
2010-04-16  7:28   ` J-P. Rosen
2010-04-16  7:48     ` Dmitry A. Kazakov
2010-04-16 15:32     ` Maciej Sobczak
2010-04-16 16:52       ` Georg Bauhaus
2010-04-16 17:24         ` Dmitry A. Kazakov
2010-04-16 20:53           ` Pascal Obry
2010-04-16 21:51             ` Dmitry A. Kazakov
2010-04-16 20:20       ` J-P. Rosen
2010-04-16 20:50         ` Maciej Sobczak
2010-04-17  5:25           ` J-P. Rosen
2010-04-17  7:00             ` Dmitry A. Kazakov
2010-04-17 11:40               ` J-P. Rosen
2010-04-17 14:09                 ` Dmitry A. Kazakov
2010-04-17 14:33             ` Maciej Sobczak
2010-04-17 18:57               ` J-P. Rosen
2010-04-17 22:02                 ` Maciej Sobczak
2010-04-18  8:04                   ` J-P. Rosen
2010-04-18 20:17                     ` Maciej Sobczak
2010-04-16  7:29   ` Dmitry A. Kazakov
2010-04-16 10:34   ` xavier grave
2010-04-16 19:26     ` Gautier write-only
2010-04-18  0:27 ` Gene
2010-04-18 20:38 ` Gautier write-only
2010-04-19  8:46   ` Maciej Sobczak [this message]
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox