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-7-bit Path: g2news2.google.com!news4.google.com!newshub.sdsu.edu!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: Thu, 18 Jan 2007 10:41:18 -0600 From: Ludovic Brenta Newsgroups: comp.lang.ada Subject: Re: Translating an embedded C algorithm References: <1168871816.263502.212100@11g2000cwr.googlegroups.com> <45acc0c3$0$22514$39db0f71@news.song.fi> <45af9c60$0$22524$39db0f71@news.song.fi> Date: Thu, 18 Jan 2007 17:41:17 +0100 Message-ID: <87y7o01e4y.fsf@ludovic-brenta.org> User-Agent: Gnus/5.110006 (No Gnus v0.6) Emacs/21.4 (gnu/linux) Cancel-Lock: sha1:MfnbBXZsfsJqo8XadHE60eEPnY0= MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii NNTP-Posting-Host: 62.235.206.39 X-Trace: sv3-FORY0lRlgC8w11pEcmdFg98dBoGU8w2iHR57bvM03m+h3FO67oEyCdMmiqbW3KdazpLrKyvhdRARaOl!PP0hiW3ajQimk8hAjqUP4E34udV+SOfS+p3IeeNZW1SgFLRAQNuuBY2eiiNDuuBQ3frcKtMkrw== 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:8264 Date: 2007-01-18T17:41:17+01:00 List-Id: Niklas Holsti writes: [...] Hi Niklas, I think your program is excellent. You are the first who used a fixed point real type and never to return an "invalid" temperature; both were the Right Thing to Do, IMHO. Would you like to work in avionics? :) Given the very high quality of your program, I'll offer only nit-picking criticisms :) > The function to convert ADC counts to temperatures then seems suitable > for a child of package ADC. It does not need to be a child of ADC; it could be another top-level package. Better yet, reverse the relationship to hide the ADC in a private child package: package Thermometer is function Temperature return Temperatures.Reading_T; function Temperature return Temperatures.Celsius_T; Out_Of_Range : exception; end Thermometer; private package Thermometer.Some_Particular_Kind_Of_Sensor is type Count_T is range 0 .. 1024; ... end Thermometer.Some_Particular_Kind_Of_Sensor; Of course, that also encapsulates the reading of the Count from the sensor, thus requiring a change in the way the function was specified. -- Ludovic Brenta.