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,f822ae7b0f7433c1 X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,UTF8 Path: g2news2.google.com!news3.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!local01.nntp.dca.giganews.com!nntp.scarlet.biz!news.scarlet.biz.POSTED!not-for-mail NNTP-Posting-Date: Wed, 17 Jan 2007 04:26:33 -0600 From: Ludovic Brenta Newsgroups: comp.lang.ada Subject: Re: AW: Translating an embedded C algorithm References: Date: Wed, 17 Jan 2007 11:26:32 +0100 Message-ID: <878xg2aqzr.fsf@ludovic-brenta.org> User-Agent: Gnus/5.110006 (No Gnus v0.6) Emacs/21.4 (gnu/linux) Cancel-Lock: sha1:rCz4uGIDZH8xbRAwcsb3T5Jnxvc= MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit NNTP-Posting-Host: 62.235.195.39 X-Trace: sv3-tneyEDwQtDmoMoTe92eQs53bjjEMUAc2aBsHiRDJbGMNd1fv5Z7T7brCQu5ryh8Sc5/W0Uz9kB0TEdJ!17ohnPJ4G8QTlzUR4YS/uDPemBl8ib9nR5KgwFkQwceJu4jFo7nDUBAzYjoCiBqcIUgXTmCGPQ== X-Complaints-To: abuse@scarlet.be X-DMCA-Complaints-To: abuse@scarlet.biz X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your complaint properly X-Postfilter: 1.3.32 Xref: g2news2.google.com comp.lang.ada:8218 Date: 2007-01-17T11:26:32+01:00 List-Id: Grein, Christoph (Fa. ESG) writes: > No, there are again some mistakes: > > ... >> --| Temperature in ÂșC x 10. INVALID_TEMPERATURE if out of range. > > Incorrect: There's no INVALID_TEMPERATURE > > ... >> InterpolationDistance := (Adc_Count - MINIMUM_ADC_COUNT) mod (SPACING - 1); > > Wrong again: mod Spacing > > But: As others have pointed out, a mere translation of C code is not > Ada. You would use constrained types rather than Integer and other > Ada idioms (put it in a package, add context clauses, use different > integer types for different abstractions etc...). Right, and there would be no need for a silly INVALID_TEMPERATURE. What *is* an invalid temperature anyway? One that needs crutches? One that is excused from military service? And why would you ever return an invalid temperature to your caller? etc. etc. -- Ludovic Brenta.