From -1624868335969647505
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: f78e5,7538bd92d6a9557a,start
X-Google-Attributes: gidf78e5,public
X-Google-ArrivalTime: 1995-01-13 17:18:21 PST
Newsgroups: comp.std.c++
Path: nntp.gmd.de!newsserver.jvnc.net!howland.reston.ans.net!ix.netcom.com!netcom.com!scotty
From: scotty@netcom.com (J Scott Peter)
Subject: short enum, bool
Message-ID: <scottyD2DFML.MDt@netcom.com>
Organization: NETCOM On-line Communication Services (408 261-4700 guest)
X-Newsreader: TIN [version 1.2 PL1]
Date: Sat, 14 Jan 1995 01:18:21 GMT
Lines: 61

Forgive me if this has been addressed already.

In the same way that one can specify an int or unsigned int as long or short,
one should be able to specify other integral types (i.e.  enums and bools) as
long, short, or char sized.

This is desirable in order to:
    Save space.  Enums are a great convenience, and the new bool type is as
    well.  But if one wants to have a char-or short-sized variable, to save
    space in a structure or array, one has to declare a char or short.  One
    loses the semantics of the enum or bool.

    Conform to operating-system structures.  Many structures used by OS
    system calls contain char-or short-sized fields which have the semantics
    of a bool or enum.  It would be better to declare them as such in the
    structure definition, but this is currently impossible.

It is *not* sufficient to have a compiler-flag for `short' enums or bools.
This would not allow one to choose when and where to make enums/bools shorter
than int, to conform to a particular structure.

Suggested behavior:
    The following constructs are syntactically equivalent.  They serve
    to modify the semantics of a byte/short/int/long variable:

        signed
        unsigned
        bool
        enum <tag>

    In order to allow byte-sized bools/enums, a new keyword `byte', with the
    same syntactical behavior as `short' and `long' should be created.

    This is better than using `char' to declare byte-sized integers, because
    you don't have to change the syntactical behavior of `char'.
    Furthermore, you could then distinguish between ASCII characters and
    byte-sized integers.  A byte variable would promote to an int, and
    overload like an int.  A byte enum <tag> variable would overload like
    enum <tag>, etc.  A char variable would still overload like a char.

    (Without creating a new keyword, one could make `short short' do the same
    thing.  Any reasonable programmer would then `#define byte short short').

Example usages:
    enum greeting { Yo, Mama, Eats, My, Shorts };

    greeting a;        // int-sized
    short greeting b;  // short-sized
    byte greeting d;   // byte-sized
    greeting byte e;   // same thing

    byte bool f;
    bool byte g;

    typedef byte greeting grtng;
    grtng h;                // byte-sized

-- 
J Scott Peter XXXIII   //  Wrong thinking is punishable.
scotty@netcom.com     //  Right thinking is as quickly rewarded.
Los Angeles          //  You will find it an effective combination.


