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.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,90f687f65a66617e X-Google-Attributes: gid103376,public From: kst@sd.aonix.com (Keith Thompson) Subject: Re: Simple ADA/C Question Date: 1997/03/06 Message-ID: #1/1 X-Deja-AN: 223540702 Sender: news@thomsoft.com (USENET News Admin @flash) X-Nntp-Posting-Host: pulsar References: <01bc23b2$ecc64960$64e2b8cd@p5120.bda> <331c6ca7.792732@news.demon.co.uk> Organization: Aonix, San Diego, CA, USA Newsgroups: comp.lang.ada Originator: kst@pulsar Date: 1997-03-06T00:00:00+00:00 List-Id: > Keith argues for always using the interfaces type. Fine, I understand the > argument, but there is no question that this leads to lots of extra code, > and many people avoid it, and I don't think that's so terrible (no worse > than using any other implementation dependent feature of a compiler. Probably > Keith likes to stay away from all such -- but many users are quite content > with adopting a style that is at least portable from GNAT to GNAT. I would hope that users would remember that GNAT isn't the only Ada compiler out there. (See my signature.) No, I don't know of any Aonix or other compiler for which Integer and Interfaces.C.int have different representations, but then I'm not very familiar with our Intel products. > Keith suggests > > << subtype Assertion is Boolean range True .. True; > Integer_Same_Size : constant Assertion > := Interfaces.C.int'Size = Standard.Integer'Size; > >> > > Less writing, and guaranteed to not merely give a warning, but to be > illegal if the assumption is violated is: > > X : Integer := 1 / Boolean'Pos (Interfaces.C.int'Size = Integer'Size); Hmm. I find the "Assertion" version easier to read, but to each his own. In your example, I'd make X a named number rather than an Integer variable, to make it clearer that the expression is static and therefore illegal if it raises an exception. The rules for static expressions are tricky enough that it's worth being more explicit. > Note incidentally that Standard.Integer does not guarantee that you will > get the integer in standard, there is no way to do that in general! > So it is probably unnecssary pedantry. My intent was to make it explicit that this is the predefined type Integer. No biggie. > As for Keith's guess that there could be C compilers that disagree on > int size, I doubt it. Keith are you aware of all the discussions going > on around C sizes on 64-bit machines? I've heard a little about the discussions, but I don't remember the details. In any case, code that implicitly assumes that Interfaces.C.int and Integer have the same representation not only requires that they have the same representation, but that the reader of the code *knows* that they have the same representation. So, Robert, would you argue that Interfaces.C.int is unnecessary, and that code should always assume that int and Integer are the same size? If not, when is it appropriate to use Interfaces.C.int? In another article, john@assen.demon.co.uk (John McCabe) wrote: > All the guy wanted to know was what was wrong with his program! Yes, and that was answered a while ago. Now the discussion has gone on to other things. Such is Usenet. -- Keith Thompson (The_Other_Keith) kst@sd.aonix.com <*> TeleSo^H^H^H^H^H^H Alsy^H^H^H^H Thomson Softw^H^H^H^H^H^H^H^H^H^H^H^H^H Aonix 10251 Vista Sorrento Parkway, Suite 300, San Diego, CA, USA, 92121-2706 "Humor is such a subjective thing." -- Cartagia