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,c98f618755b0ddcc X-Google-Attributes: gida07f3367d7,public,usenet X-Google-NewGroupId: yes X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news4.google.com!feeder.news-service.com!cyclone01.ams2.highwinds-media.com!news.highwinds-media.com!npeersf01.ams.highwinds-media.com!newsfe26.ams2.POSTED!7564ea0f!not-for-mail From: John McCabe Newsgroups: comp.lang.ada Subject: Re: Thinking of using Ada for a job at home. Couple of questions first. Message-ID: References: X-Newsreader: Forte Agent 2.0/32.652 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit NNTP-Posting-Host: 80.176.146.77 X-Complaints-To: abuse@demon.net X-Trace: newsfe26.ams2 1267646982 80.176.146.77 (Wed, 03 Mar 2010 20:09:42 UTC) NNTP-Posting-Date: Wed, 03 Mar 2010 20:09:42 UTC Date: Wed, 03 Mar 2010 20:09:40 +0000 Xref: g2news1.google.com comp.lang.ada:9381 Date: 2010-03-03T20:09:40+00:00 List-Id: Hi Jeff "Jeffrey R. Carter" wrote: >John McCabe wrote: >> >> The second question is related to the implementation of the System >> Exclusive messages. Basically this is part of the reason I thought Ada >> would be good for this task. The SysEx messages basically consist of a >> smallish header and a variety of different structures that are >> differentiated by the "Function" type in the header. Now I seem to >> remember from when I did use Ada that it's possible to define the >> record representation of a variant record such that the discriminant >> is held within the body of the record. This would mean (I think) that >> I could read a block of data from the synthesizer straight in to a >> buffer that overlaid the variant record and essentially automatically >> created a record that could be read as the particular variant related >> to the incoming data. However I also seem to remember that's not quite >> a 'recommended' way of doing that sort of thing. The other thing that >> guided me in Ada's direction is that the structure of the SysEx >> messages requires a lot of bit-fields and I'm well aware that Ada's >> representation clauses are fantastic for that sort of thing. >> >> So, in principle, would that be the way to do this, or would you be >> able to suggest a better mechanism? > >That is the way I would approach this, though I might keep the buffer and record >separate and use Unchecked_Conversion. Thanks for taking the time to answer that. The Unchecked_Conversion option was the other thing I was thinking of. >I can't tell you whether the tagged approach would work, because programming by >extension is a bad idea, and I avoid it whenever possible. It's a good laugh though, and can be a useful think to know about if your work doesn't involve anything that needs to be particularly fast, reliable or safe :-}