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,FREEMAIL_FROM autolearn=unavailable autolearn_force=no version=3.4.4 Path: border2.nntp.dca1.giganews.com!border1.nntp.dca1.giganews.com!nntp.giganews.com!newspeer1.nac.net!feeder.erje.net!eu.feeder.erje.net!news2.arglkargh.de!news.mixmin.net!aioe.org!.POSTED!not-for-mail From: Victor Porton Newsgroups: comp.lang.ada Subject: Re: 'Size hack for enumerated types Date: Sun, 06 Jul 2014 19:16 +0300 Organization: Aioe.org NNTP Server Message-ID: References: NNTP-Posting-Host: BISA/P8IHJbAM3ms471zeQ.user.speranza.aioe.org Mime-Version: 1.0 Content-Type: text/plain; charset="ISO-8859-1" Content-Transfer-Encoding: 7Bit X-Complaints-To: abuse@aioe.org User-Agent: KNode/4.12.4 X-Notice: Filtered by postfilter v. 0.8.2 Xref: number.nntp.dca.giganews.com comp.lang.ada:187393 Date: 2014-07-06T19:16:00+03:00 List-Id: sbelmont700@gmail.com wrote: > On Saturday, July 5, 2014 4:32:10 PM UTC-4, Victor Porton wrote: >> >> What is a better way to do this? >> > > I prefer something along these lines: > > type T is (x, y, z); > > K : constant array (T) of Interfaces.C.int := > (x => 1, > y => 2, > z => 3); > > C_Function(arg => K(x)); > > > You lose a little by having to declare the array (assuming it cannot be > optimized away), but can have any size you desire for T, plus you get to > explicitly specify how the enum maps. Your way does not work backward (K^{-1}). -- Victor Porton - http://portonvictor.org