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: 103376,24d7acf9b853aac8 X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news1.google.com!news.glorb.com!news.netfront.net!not-for-mail From: Jeffrey Carter Newsgroups: comp.lang.ada Subject: Re: S-expression I/O in Ada Date: Mon, 09 Aug 2010 12:06:52 -0700 Organization: Netfront http://www.netfront.net/ Message-ID: References: <547afa6b-731e-475f-a7f2-eaefefb25861@k8g2000prh.googlegroups.com> <46866b8yq8nn$.151lqiwa0y2k6.dlg@40tude.net> <13b07f2c-2f35-43e0-83c5-1b572c65d323@y11g2000yqm.googlegroups.com> <13tpf7ya3evig$.h05p3x08059s$.dlg@40tude.net> <1omt2srxtpsga$.c3hbxthzo6cf.dlg@40tude.net> <1e4cch2df5uyb.18brqdd16dhv8.dlg@40tude.net> <14y70ke8am9qw$.2csc9eflvigg.dlg@40tude.net> <4c601b5c$0$7665$9b4e6d93@newsspool1.arcor-online.net> NNTP-Posting-Host: 75.211.157.188 Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Trace: adenine.netfront.net 1281380825 47075 75.211.157.188 (9 Aug 2010 19:07:05 GMT) X-Complaints-To: news@netfront.net NNTP-Posting-Date: Mon, 9 Aug 2010 19:07:05 +0000 (UTC) User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.11) Gecko/20100713 Thunderbird/3.0.6 In-Reply-To: Xref: g2news1.google.com comp.lang.ada:13007 Date: 2010-08-09T12:06:52-07:00 List-Id: On 08/09/2010 11:32 AM, Natacha Kerensikova wrote: > > In C for such things I usually use a struct bitfield. I guess the Ada > equivalent would be a record of Booleans, with a pragma or something > to have them packed together. Would there be anything wrong with that? > It seems to me more readable than the above IFs, though from what I > understood from the rest of the thread it would make CASE on multiple > bit difficult, and it won't allow slicing (which I'm not sure is a bad > thing, readability-wise). Is there anything else? Typically, I would address it using: type Mode_ID is (Alarm, ...); type Mode_Set is array (Mode_ID) of Boolean; for Mode_Set'Component_Size use 1; Mode : Mode_Set; if Mode (Alarm) then ... Of course, I'd usually leave off the 'Component_Size definition; memory is usually cheap and plentiful these days. Only if I had to match an existing bit-packed representation, or Mode_ID was very large [array (Integer) of Boolean, anyone?] would I worry about the representation. -- Jeff Carter "Run away! Run away!" Monty Python and the Holy Grail 58 --- news://freenews.netfront.net/ - complaints: news@netfront.net ---