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,a1ce307c10055549 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2002-12-17 07:49:02 PST Message-ID: <3DFF46F9.9060703@cogeco.ca> From: "Warren W. Gay VE3WWG" User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.0.1) Gecko/20020823 Netscape/7.0 X-Accept-Language: en-us, en MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: calenday (was Re: IBM Acquires Rational Ada References: <3DF1615C.7AAAC86E@adaworks.com> <8db3d6c8.0212091445.12594821@posting.google.com> <3DF628C4.7090607@cogeco.ca> <3DF6653D.3030603@cogeco.ca> <8db3d6c8.0212101850.51506572@posting.google.com> <3DF8D33F.9020205@cogeco.ca> <3DFE1D97.6020109@cogeco.ca> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Date: Tue, 17 Dec 2002 10:47:05 -0500 NNTP-Posting-Host: 198.96.47.195 X-Complaints-To: abuse@sympatico.ca X-Trace: news20.bellglobal.com 1040140026 198.96.47.195 (Tue, 17 Dec 2002 10:47:06 EST) NNTP-Posting-Date: Tue, 17 Dec 2002 10:47:06 EST Organization: Bell Sympatico Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!cyclone.bc.net!torn!webster!nf1.bellglobal.com!nf2.bellglobal.com!news20.bellglobal.com.POSTED!not-for-mail Xref: archiver1.google.com comp.lang.ada:31962 Date: 2002-12-17T10:47:05-05:00 List-Id: Bill Findlay wrote: > On 16/12/02 21:41, in article > mailman.1040074922.28258.comp.lang.ada@ada.eu.org, "David C. Hoos" > wrote: > > [snip] > >>>>>On 16/12/02 18:38, in article 3DFE1D97.6020109@cogeco.ca, "Warren W.Gay >>>>>VE3WWG" wrote: >>>>> >>>>>>I would suggest one more small point WRT to: >>>>>> >>>>>>type day_name_type is (mon,tue,wed,thu,fri,sat,sun); >>>>>> >>>>>>Add a representation clause to guarantee that the values >>>>>>start with sun => 0, mon => 1 etc. For some code, it is >>>>>>much easier to work with the day of the week in the form >>>>>>of a number. >>>>> > >>Suppose you have an array of day_name_type that you want to >>convert to an array of numbers. It's much cheaper to use >>Unchecked_Conversion than it is to loop through the array and >>call the 'Pos function or the 'Val function on each element of >>the array. > > Isn't mon => 0, ..., sun => 6 guaranteed to be the > encoding of this type in any case, even without a > representation clause? > > Defining sun => 0, mon => 1, inconsistently with 'Pos, is going > to create a distributed inefficiency in processing this type. > > Can you see this being worth the hypothetical saving in unchecked array > conversion? (We are discussing unconditional advice here.) Actually, I was not thinking of Unchecked_Conversion when I suggested the representation clause. You are right in that the 'Pos(mon) is zero anyway (I didn't know that this was guaranteed by the language). It is also apparently bad practice to rely on the representation, because I get the impression that some Ada compilers may ignore the representation clause. My question now is, why is Monday first? My own personal preference would be to have Sunday first to be consistent with the UNIX practice in the use of localtime/gmtime and mktime(3C) routines. Was there a reason that Monday was chosen as the first in this series? TIA, Warren. -- Warren W. Gay VE3WWG http://home.cogeco.ca/~ve3wwg