From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.5-pre1 (2020-06-20) on ip-172-31-74-118.ec2.internal X-Spam-Level: X-Spam-Status: No, score=-1.9 required=3.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.5-pre1 Date: 10 Dec 91 12:30:37 GMT From: mcsun!uknet!yorkohm!minster!mjl-b@uunet.uu.net Subject: Re: 'SIZE attribute of a type Message-ID: <692368237.5256@minster.york.ac.uk> List-Id: In article <1991Dec7.003222.17204@titan.tsd.arlut.utexas.edu> gardner@tsd.arlut .utexas.edu (Donald Gardner) writes: >parkhill@email.sp.unisys.com (parkhill) writes: >>Image a compiler was smart enough to understand baised number ranges. > >> type b is range 9 .. 10; >> or >> type b is range 2**31 - 2 .. 2**31 - 1; > > >>If the compiler can generate code that only uses 1 bit then b'Size >>should return 1. > >Oh, that compilers were so cleverly written! > >Consider an application that is transferring data over a slow serial >channel. If a compiler used the minimum number of bits needed to >represent a type and the number of bits used was readily available >(hopefully from the 'SIZE attribute), the task of maximizing >communications throughput would be simplified. Yes, but if you _aren't_ writing a package that transfers data over a slow serial link, you want fast, efficient code. Using one bit to represent the above examples is neither fast nor efficient (and it adds to compile time and compiler complexity). If you want to use the smallest number of bits (for the transmission example), then use a 'case' statement and convert it to a packed boolean yourself. The time taken to do the conversion will be minimal compared to the time taken to do the transmission. Mathew |Mathew Lodge | "Baldrick, are the words 'I have a cunning plan' | |mjl-b@minster.york.ac.uk | heading towards this conversation with ill | |Summer: lodge%alsys@uknet| deserved confidence?" -- Blackadder III |