From: Ludovic Brenta <ludovic@ludovic-brenta.org>
Subject: Re: AW: Translating an embedded C algorithm
Date: Wed, 17 Jan 2007 11:26:32 +0100
Date: 2007-01-17T11:26:32+01:00 [thread overview]
Message-ID: <878xg2aqzr.fsf@ludovic-brenta.org> (raw)
In-Reply-To: mailman.27.1169017665.18371.comp.lang.ada@ada-france.org
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.
next prev parent reply other threads:[~2007-01-17 10:26 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <E473CA319B6D514981A06AE6742A1FD82B067D@GLDMS10607.goldlnk.rootlnka.net>
2007-01-17 7:07 ` AW: Translating an embedded C algorithm Grein, Christoph (Fa. ESG)
2007-01-17 10:26 ` Ludovic Brenta [this message]
2007-01-17 16:44 ` Markus E Leypold
2007-01-18 8:49 ` Ludovic Brenta
2007-01-18 9:53 ` Markus E Leypold
2007-01-19 9:33 ` Stephen Leake
2007-01-19 19:23 ` Cesar Rabak
2007-01-19 20:27 ` Robert A Duff
2007-01-19 23:15 ` Cesar Rabak
2007-01-20 9:54 ` Dmitry A. Kazakov
2007-01-20 21:03 ` AW: " Jeffrey Carter
2007-01-20 21:38 ` Robert A Duff
2007-01-22 2:30 ` Jeffrey Carter
2007-01-23 7:43 ` Stephen Leake
2007-01-23 19:34 ` Jeffrey R. Carter
[not found] ` <1%trh.15628$X72.889@newsread3.news.pas.earthlink.net>
2007-01-17 18:44 ` Niklas Holsti
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox