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-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,751584f55705ddb7 X-Google-Attributes: gid103376,public From: ok@goanna.cs.rmit.EDU.AU (Richard A. O'Keefe) Subject: Re: Ada is almost useless in embedded systems Date: 1996/02/21 Message-ID: <4gechc$g26@goanna.cs.rmit.EDU.AU> X-Deja-AN: 140374308 references: <823906039.22113@assen.demon.co.uk> <4fgrq3$mc4@qualcomm.com> <4g54r5$57j@toads.pgh.pa.us> <824760880.18193@assen.demon.co.uk> organization: Comp Sci, RMIT, Melbourne, Australia newsgroups: comp.lang.ada Date: 1996-02-21T00:00:00+00:00 List-Id: john@assen.demon.co.uk (John McCabe) writes: >I honestly believed that I would receive intelligent responses >explaining all the good features of Ada for embedded systems but I was >obviously a bit naive. With all due respect, it is a mystery to me how anyone could have expected a posting whose title is "Ada is almost useless..." to be perceived as anything other than flame bait. When the first thing you say is, in effect, "I know you have nothing worthwhile to tell me", you have no right to be surprised if you fail to receive the response you expected. >1) Strong Typing is also very good if you have a large system with a >large number of programmers. Obviously it is advisable to catch errors >as early as possible as the later you find them, the more expensive >they tend to be to find. Also I have seen an article on 'lint' and its >usage and there are some very good points in it related to the fact >that it gives a lot of detail about trivial errors which can lead to >the user unintentionally ignoring the serious errors! In defence of Lint, I have to say that all of the things it reports are likely symptoms of serious errors, and that it is next door to impossible to UNINTENTIONALLY ignore the serious errors. The only way you can ignore the serious errors is by not tracking down all the lint reports to see how serious they are. A typical experience with someone else's code might be - 16 000 lines of source code - 1 000 lines of lint warnings - 10 hours checking the lint warnings - 10 days fixing the serious bugs. Many categories of warnings can easily be switched off. There are two real problems with lint. (1) The declarations of C do not provide enough information for really effective checking. (E.g. all integer types are compatible.) (2) There are legions of C programmers who apply lint, if at all, far too late in the life cycle, after they have already populated their code with tons of lint. >2) Bitwise logical functions - can be used on one dimensional packed >arrays of booleans. But you didn't need the net for this. It's in the manual! Think "logical", find "logical operators" in the Ada83 LRM, go to section 4.5.1 "Logical Operators and Short-Circuit Control Forms",, and there staring you in the fact is a table that says 'and', 'or', 'xor' apply to "array of boolean components". >3) Enumeration representation clauses - I knew that I could get round >the problem I described and I now also know the reasons why the >restrictions exist although I have not really changed my opinion on >that point. Richard O'Keefe pointed out the Ada 95 definition of these >clause, but I have not managed to obtain the Ada 95 LRM yet to get the >exact context so I cannot really comment for the moment. For the sake of completeness, I should point out the possibility of generating the Ada source text. I can well imagine that if your primary source for the names and values of the enumeration literals puts them in some funny order, then you might want the manually edited document to have them in the same order so that they can be the more easily checked. Let your codes document have the form ... with the entries in the order of your primary source. Call this file typename.org You want to generate type is ( -- ... , -- ); for use ( => ... , => ); in a file called typename.ada Put the following shell script in a file called mk-ada-enum: #!/bin/sh typename=$1 echo "type $typename is (" echo "for $typename use (" >$$.use separator=" " sort -n | while read number identifier comment ; do echo "$separator$identifier -- $comment" echo "$separator$identifier => $number" >>$$.use separator="," done echo ");" echo ");" >>$$.use cat $$.use rm $$.use Use it like this: mk-ada-enum "Ada_Type_Name" typename.ada For example, I put these lines in "funny.org": 4 foo "d" is not supported 1 bar not a wet one 3 ick the shut down signal 2 ugh response to the shut down signal Running "mk-ada-enum Funny funny.ada" produced this output: type Funny is ( bar -- not a wet one ,ugh -- response to the shut down signal ,ick -- the shut down signal ,foo -- "d" is not supported ); for Funny use ( bar => 1 ,ugh => 2 ,ick => 3 ,foo => 4 ); It isn't pretty, but that doesn't matter, because you maintain the table, not the generated Ada code. (The scripting language isn't important; if it were in TCL I could run it on a Macintosh.) -- Election time; but how to get Labour _out_ without letting Liberal _in_? Richard A. O'Keefe; http://www.cs.rmit.edu.au/~ok; RMIT Comp.Sci.