Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!utgpu!water!watmath!clyde!rutgers!husc6!bu-cs!bzs From: bzs@bu-cs.UUCP Newsgroups: comp.lang.c Subject: Re: Standard int sizes Message-ID: <6588@bu-cs.BU.EDU> Date: Wed, 15-Apr-87 18:10:01 EST Article-I.D.: bu-cs.6588 Posted: Wed Apr 15 18:10:01 1987 Date-Received: Fri, 17-Apr-87 03:45:23 EST References: <6759@brl-adm.ARPA> <230@ems.UUCP> <170@vianet.UUCP> <3286@pogo.TEK.COM> <103@buengc.BU.EDU> Distribution: na Organization: Boston U. Comp. Sci. Lines: 46 In-reply-to: shaun@buengc.BU.EDU's message of 15 Apr 87 22:01:30 GMT Posting-Front-End: GNU Emacs 18.41.4 of Mon Mar 23 1987 on bu-cs (berkeley-unix) It seems clear to me that if there is to be any alternate approach to declaring portable integer sizes then Pascal (lord forgive me) had the right approach. Let the programmer declare a range and then let that be resolved automatically in a machine independant way: int foo range {-10000..10000}; And forget about how many bits/bytes are needed as you're not sure what the right thing is anyhow in advance. This proposal involves saying exactly what you mean. Too much trouble to specify a range? Not known in advance? Ooops, you got bugs (or you're always defaulting to max.) This could probably be handled adequately by a simple C pre-pre-processor which picked up the ranges and replaced them with the appropriate declarations, I could imagine: INT(-10000,10000) foo, bar; INT(0,255) baz; as an easily parsed syntax, although not terribly aesthetic. Perhaps doing it as psuedo-typedefs would be superior: #TYPEDEF int with range {-10000,10000} medium_int #TYPEDEF int with range {0,255} small_int ... medium_int foo, bar; small_int baz; You can almost do this with the pre-processor but it's hard to nest #if's intelligently into #defines (maybe someone has an idea.) The important thing is looking at the range specs and deciding intelligently which is the best type to use. Just defining a bunch of small_int defines is not powerful enough (tho I'd love to be convinced otherwise, it would simplify this.) The output would be normal typedefs. Note that this, I claim, solves the range problem in a portable way without requiring any modification in the language definition, just a utility (in the spirit of YACC or LEX.) -Barry Shein, Boston University