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=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,1cd9f7e5a0d12003 X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Received: by 10.68.223.40 with SMTP id qr8mr23598443pbc.0.1337615142413; Mon, 21 May 2012 08:45:42 -0700 (PDT) Path: pr3ni21052pbb.0!nntp.google.com!news1.google.com!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail From: Adam Beneschan Newsgroups: comp.lang.ada Subject: Re: condition true or false? -> (-1 < sizeof("test")) Date: Mon, 21 May 2012 08:45:41 -0700 (PDT) Organization: http://groups.google.com Message-ID: <49eaf626-d504-472c-ae3b-cdb78595a82c@googlegroups.com> References: <95634f38f6ee0d116da523fdc2c9f5ca@dizum.com> <00240c6dd26962f50d5c57a933c137ef@dizum.com> NNTP-Posting-Host: 66.126.103.122 Mime-Version: 1.0 X-Trace: posting.google.com 1337615142 20164 127.0.0.1 (21 May 2012 15:45:42 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Mon, 21 May 2012 15:45:42 +0000 (UTC) In-Reply-To: <00240c6dd26962f50d5c57a933c137ef@dizum.com> Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=66.126.103.122; posting-account=duW0ogkAAABjRdnxgLGXDfna0Gc6XqmQ User-Agent: G2/1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Date: 2012-05-21T08:45:41-07:00 List-Id: On Monday, May 21, 2012 8:28:44 AM UTC-7, Nomen Nescio wrote: > Forwarding this to guys who write code in real languages to see what they > think of this. AFAIK you cannot get something like that past the compiler= in > Ada...and you would have to define a type or a subtype to even have an > unsigned int unless you use a modular type IIRC. The last part is pretty much correct. If you do something like this in Ada= : =20 B :=3D -1 < Some_Type'Size; where B is a Boolean, it works like this: Some_Type'Size is a universal int= eger, and it can be converted to any integer type. However, in a case like= this where there's no variable or anything else that tells the language wh= ich type to use, the language has a preference for "root_integer", which is= a signed integer type. So the above would do what you expect (i.e. set B = to True since 'Size can never be negative). (The rule about preferring roo= t_integer was added in Ada 95. I don't know for sure whether the above is = legal in Ada 83; I think this might have been an error.) You could create a situation where -1 is treated as a modular type expressi= on, so that the above would set B to False. However, you really have to tr= y. For instance: type Word is mod 2**32; B :=3D -1 < Word' (Some_Type'Size); would cause Some_Type'Size to be interpreted as a Word, and then the - and = < operators are treated as the ones that operate on Word. Or: One : constant Word :=3D 1; B :=3D -One < Some_Type'Size; But you do have to have some modular type involved to get False for B, and = you have to either use the type name in the expression, use the name of an = object of that type, or do something like B :=3D Thing_Defining_Modular_Type."<" (-1, Some_Type'Size); It won't happen implicitly. -- Adam