From -8958256907743200538
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f78e5,7538bd92d6a9557a
X-Google-Attributes: gidf78e5,public
X-Google-ArrivalTime: 1995-01-16 08:41:18 PST
Newsgroups: comp.std.c++
From: kevlin@wslint.demon.co.uk (Kevlin Henney)
Path: nntp.gmd.de!Germany.EU.net!EU.net!howland.reston.ans.net!news.sprintlink.net!peernews.demon.co.uk!wslint.demon.co.uk!kevlin
Subject: Re: short enum, bool
Distribution: world
References: <scottyD2DFML.MDt@netcom.com> <3f9n22$es3@engnews2.Eng.Sun.COM> <3fa97p$b85@ixnews3.ix.netcom.com>
Organization: Westinghouse Systems Ltd.
Reply-To: Kevlin@wslint.demon.co.uk
X-Newsreader: Demon Internet Simple News v1.27
Lines: 39
X-Posting-Host: wslint.demon.co.uk
Date: Mon, 16 Jan 1995 16:41:18 +0000
Message-ID: <790274478snz@wslint.demon.co.uk>
Sender: usenet@demon.co.uk

In article <3fa97p$b85@ixnews3.ix.netcom.com>
           PGoodwin@ix.netcom.com "Phil Goodwin" writes:

[stuff about choosing efficient sizes for enums deleted]
>That behavior takes just a little too much power out of the programmers hands. 
>if an "efficient" size isn't the same size as an 'int' (I apologize for not 
>being quite up to date) I think that this would also lead to unexpected 
>behavior.

Given that the programmer didn't have that 'power' in the first place, in
either C or C++, nothing is lost I'm afraid.

[...]
>If I remember correctly the DEVMODE structure in the Windows operating system 
>uses the same declaration for both 16 and 32 bit environments. Although the 
>declarations are the same the sizes of the members are not because of the
> native 
>size of an 'int' on the different platforms. It would be handy to be able to 
>declare a member of such a structure as 'short' or 'long' in order to have some
> 
>guarantees about its size that are consistent with the guarantees made for the 
>other members of that structure, and it would be nice to be able to further 
>modify the type of that member by using an 'enum' or 'bool' specifier that 
>limits the values that the member can legally hold. 

You get guarantees about minimum precision with short and long, and that's
your lot. A bool can legally hold true or false, and an enum can legally
hold up to the next power of 2 that the value of the highest declared
constant for that enum rounds up to. These are also minimum guarantees.
They sound pretty good to me :-)

Only problems need solutions, and since there is no problem here no change
to the language is needed ;-)

+---------------------------+-------------------------------------------+
| Kevlin A P Henney         | Human vs Machine Intelligence:            |
| kevlin@wslint.demon.co.uk | Humans can wreck a nice beach more easily |
| Westinghouse Systems Ltd  |                                           |
+---------------------------+-------------------------------------------+


