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,2ceb82769e7e23b X-Google-Attributes: gid103376,public From: dewar@merv.cs.nyu.edu (Robert Dewar) Subject: Re: Help needed in port to GNAT95 from verdix Date: 1998/05/14 Message-ID: #1/1 X-Deja-AN: 353354513 References: <6jcvoc$drd$1@plug.news.pipex.net> <355B227D.2858F2BD@elca-matrix.ch> <355B319B.BAFDC332@earthling.net> X-Complaints-To: usenet@news.nyu.edu X-Trace: news.nyu.edu 895190778 1117 (None) 128.122.140.58 Organization: New York University Newsgroups: comp.lang.ada Date: 1998-05-14T00:00:00+00:00 List-Id: Bob Duff said <> Technically true, but *highly* misleading. The RM is badly flawed in the area of size (the 83 RM was better, because it left things looser, the Ada 95 RM tried to tighten things up and got it wrong!) Yes, it is true that Byte'Size will be 8 by default (because this is what the Ada 95 -- rather mistakenly -- requires). But the Ada 95 RM does NOT require that objects of type Byte take 8 bits. The trouble is that most people think of the size of an object as being determined by the size of the type, but that is generally not true in Ada 95 (though it was typically true in the default case in Ada 83). Consider: type r is range 0 .. 5; A typical Ada 83 implementation will likely make the size of "r" objects be 8 bits, and set r'size to 8. A typical Ada 95 implementation will likely make the size of "r" objects be 8 bits, but r'size is required to be 3. We have found in GNAT that the most compatible approach (i.e. compatible to typical Ada 83 implementations), is to make the size of objects of a given subtype by default take up the same size as the base type, regardless of subtype range. So in GNAT: type Byte is range 0..2**8-1; since Byte'Base is obviously required to be large than 8 bits, we allocate 16 bits by default for objects of type Byte. This can of course be overridden by giving a size clause, either for the object OR FOR THE TYPE, so in GNAT for Byte'Size use 8; causes objects to by 8 bits by default. If you are only using GNAT, the entire size mess is cleaned yup nicely by use of the implenmentation defined attributes Object_SIze and Value_Size which properly separate these two aspects of Size. In Ada 83, it was left rather vague as to which of these two was being talked about. In Ada 95, the RM requires that the SIze attribute return the size of values, rather than the size of objects. That's a mistake in my view, but it's too late now. Note: the latest version of GNAT implements an attribute VADS_Size, which gives exactly the size value that would have been given by the VADS Ada 83 compiler (some of our customers found that the incompatible changes to the meaning of 'Size were just too extensive to be fixable). FOr example, the common Ada 83 paradigm for do it yourself streams, namely using 'Size on the type of an object to find out how many bits to read or write, is likely to break badly in Ada 95 ports of such code.