From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: a07f3367d7,33ce43bfeafb2681 X-Google-Attributes: gida07f3367d7,public,usenet X-Google-NewGroupId: yes X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news2.google.com!newsfeed2.dallas1.level3.net!news.level3.com!panix!bloom-beacon.mit.edu!newsswitch.lcs.mit.edu!nntp.TheWorld.com!not-for-mail From: Robert A Duff Newsgroups: comp.lang.ada Subject: Re: Concatenate enumeration Date: Mon, 23 Nov 2009 18:21:06 -0500 Organization: The World Public Access UNIX, Brookline, MA Message-ID: References: NNTP-Posting-Host: shell01.theworld.com Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: pcls6.std.com 1259018458 5951 192.74.137.71 (23 Nov 2009 23:20:58 GMT) X-Complaints-To: abuse@TheWorld.com NNTP-Posting-Date: Mon, 23 Nov 2009 23:20:58 +0000 (UTC) User-Agent: Gnus/5.1008 (Gnus v5.10.8) Emacs/21.3 (irix) Cancel-Lock: sha1:6UCJopEYs5utFsvmEXbjcd6v5rU= Xref: g2news1.google.com comp.lang.ada:8221 Date: 2009-11-23T18:21:06-05:00 List-Id: "Jeffrey R. Carter" writes: > Pablo wrote: >> type Enumerate_Type is >> ( >> NONE, >> READY >> ); >> for Enumerate_Type use >> ( >> NONE => 0, >> READY=> 1 >> ); >> for Enumerate_Type'Size use 1; >> and I want to create a new type Enumerate2_Type which could be the >> form >> type Enumerate_Type is >> ( >> NONE, >> READY, >> OFF >> ); >> for Enumerate_Type use >> ( >> NONE => 0, >> READY=> 1, >> OFF => 2 >> ); >> for Enumerate_Type'Size use 2; Note that all of the rep clauses above are unnecessary: the language defines the default rep of enums to be (0, 1, ...), and defines the 'Size to be 1 and 2 for the above. If you want to confirm the 'Size, I'd do: pragma Assert (Enumerate_Type'Size = 1); for example. >> How to I do this without having to explicit clone the first one? > > You can't. Enumeration types are not extensible. Extensible enumeration types were proposed for Ada 9X, but were dropped. > You can do something similar in the reverse direction: > > type Big is (None, Ready, Off); > > subtype Small is Big range None .. Ready; > > or > > type Small is new Big range None .. Ready; Right. And Big'Size = 2, and Small'Size = 1, by default. - Bob