From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-0.9 required=5.0 tests=BAYES_00,FORGED_GMAIL_RCVD, FREEMAIL_FROM autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: 103376,42e401e32683b965 X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news2.google.com!postnews.google.com!i40g2000yqd.googlegroups.com!not-for-mail From: Maciej Sobczak Newsgroups: comp.lang.ada Subject: Re: A new notion: stronglly-typed-by-user language Date: Mon, 19 Apr 2010 01:46:51 -0700 (PDT) Organization: http://groups.google.com Message-ID: References: <52b7b2ba-ca54-42f4-abd7-41082a49a333@e7g2000yqf.googlegroups.com> NNTP-Posting-Host: 137.138.182.236 Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 X-Trace: posting.google.com 1271666811 13479 127.0.0.1 (19 Apr 2010 08:46:51 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Mon, 19 Apr 2010 08:46:51 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: i40g2000yqd.googlegroups.com; posting-host=137.138.182.236; posting-account=bMuEOQoAAACUUr_ghL3RBIi5neBZ5w_S User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10.5; en-US; rv:1.9.2) Gecko/20100115 Firefox/3.6,gzip(gfe) Xref: g2news2.google.com comp.lang.ada:11028 Date: 2010-04-19T01:46:51-07:00 List-Id: On 18 Kwi, 22:38, Gautier write-only 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