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,ASCII Newsgroups: comp.lang.ada Subject: Re: AW: Translating an embedded C algorithm References: <878xg2aqzr.fsf@ludovic-brenta.org> <87k5zk7m8j.fsf@ludovic-brenta.org> From: Markus E Leypold Organization: N/A Date: Thu, 18 Jan 2007 10:53:09 +0100 Message-ID: User-Agent: Some cool user agent (SCUG) Cancel-Lock: sha1:guYMWB1N0nrr8WUE1Gd71yfl8BE= MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit NNTP-Posting-Host: 88.72.212.252 X-Trace: news.arcor-ip.de 1169113725 88.72.212.252 (18 Jan 2007 10:48:45 +0200) X-Complaints-To: abuse@arcor-ip.de Path: g2news2.google.com!news4.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsfeed.arcor-ip.de!news.arcor-ip.de!not-for-mail Xref: g2news2.google.com comp.lang.ada:8324 Date: 2007-01-18T10:53:09+01:00 List-Id: Ludovic Brenta writes: > Markus E Leypold writes: >> Ludovic Brenta writes: >>> 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. >> >> | >> --| Temperature in �C x 10. INVALID_TEMPERATURE if out of range. >> >> If the sensor is out of order or the temperature leaves the range >> where it functions properly? >> >> :-). > > My point it this: if the sensor is out of order, then there is no > known temperature; not a known "invalid" temperature. The proper way Yep, certainly. Actually 'temperature' is the wrong description for this type. It's actually "the result of reading the temperature sensor" which is a union type between a finite temperature range and the "invalid result". > to handle that in Ada is with an exception, That depends on how "exceptional" that event is. If it is a hardware failure an exception would perhaps be better, but if it just means "temperature went out of range" (or better "too high") dependend on what kind of apparatus we have here, it might be better to handle that as a special case (like: a very high temperature we don't don't knoe exactly). A (very primitive and perhaps incomplete) example: A temperature sensor for some kind of nuclear or chemical process. If the the temperature becomes > t2 we'd want the emergency cooling to be activated. We'd also want this if the it becomes > t3, the temperature where the sensor stops to work properly (which is higher than t2, but where we still know that the temperature is too high). In that case an exception or even an emergency shutdown of the controlling unit would be wrong. > not a special value of type Degrees_C. Agreed. Degrees_C is misleading. What about Sensor_Result? Regards -- Markus