Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!linus!philabs!cmcl2!seismo!lll-crg!nike!cad!ucbvax!hplabs!felix!peregrine!mike From: mike@peregrine.UUCP (Mike Wexler) Newsgroups: net.lang.c Subject: Re: boolean datatype Message-ID: <399@peregrine.UUCP> Date: Mon, 9-Jun-86 17:09:18 EDT Article-I.D.: peregrin.399 Posted: Mon Jun 9 17:09:18 1986 Date-Received: Fri, 13-Jun-86 01:47:47 EDT References: <5498@alice.uUCp> <1462@mmintl.UUCP> <852@bentley.UUCP> <1126@whuxl.UUCP> <393@peregrine.UUCP> <705@wjvax.wjvax.UUCP> Reply-To: mike@peregrine.UUCP (Mike Wexler) Distribution: net Organization: Peregrine Systems, Irvine, Ca Lines: 28 In article <705@wjvax.wjvax.UUCP> brett@wjvax.UUCP (Brett Galloway) writes: >In article <393@peregrine.UUCP> mike@peregrine.UUCP (Mike Wexler) writes: >>Another feature I would like to have is a range data type. I don't > >I would prefer an operator that merely generated an integral type based on >a number of bits requested, not based on a desired range. For example, >on a machine with 8-bit char, 16-bit short, 32-bit int, and 64-bit long, >bittype(8) == char; bittype(9) == short; bittype(31) == int; and so on. This is an interesting idea, but has many disadvantages. You can't even optionally turn on range checking, have the compiler check for range errors, have the compiler do things like generate a jump table for a switch statement knowing that the variable being switched on has a maximum value of 3, etc... It also puts the burden on the user to figure out how many bits are needed to store a particular number. This could lead to either less efficient code or nonportable code due to problems with signed/unsigned variables. For instance if I say I want a range of 1 thru 7 the compiler could store this in a signed or unsigned variable depending on which is most efficient. If the reason for you suggestion is that run-time range checking is expensive. This could be solved the same way it is handled on arrays, i.e. don't do it. You can always add an option to the compiler to turn on range checking. -- Mike Wexler Email address:(trwrb|scgvaxd)!felix!peregrine!mike Tel Co. address: (714)855-3923 ;-) Internet address: ucivax@ucbvax.BERKELY.EDU!ucivax%felix!mike@peregrine :-(