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 06:51:45 PST Newsgroups: comp.lang.ada Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!logbridge.uoregon.edu!uunet!sea.uu.net!sac.uu.net!ash.uu.net!world!news From: Robert A Duff Subject: Re: calenday (was Re: IBM Acquires Rational Ada User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.2 Sender: news@world.std.com (Mr Usenet Himself) Message-ID: Date: Tue, 17 Dec 2002 14:50:40 GMT Content-Type: text/plain; charset=us-ascii References: NNTP-Posting-Host: shell01.theworld.com Mime-Version: 1.0 Organization: The World Public Access UNIX, Brookline, MA Xref: archiver1.google.com comp.lang.ada:31955 Date: 2002-12-17T14:50:40+00:00 List-Id: "Grein, Christoph" writes: > > > Yes, but if what you want is "to work with the day of the week in > > > the form of a number", why use Unchecked_Conversion when > > > day_name_type'Pos does what you want without further ado? > > 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. > > This seems unbelievable with RM 13.4(8) in mind. I don't buy the unchecked-conversion-of-array efficiency argument. It might be true that unchecked conversion of an array is faster than a loop with 'Pos. And unchecked conversion of a *pointer* to the array would certainly be faster. But there is no need to resort to such low-level hackery. Keep arrays of Day_Name_Type. Whenever you need to process a particular day using arithmetic, use 'Pos and 'Val. There is never a need to have an array of days-as-integers, and there is never a need to do a whole-array conversion. Note that 'Pos and 'Val should generate zero machine code, if you stay away from enumeration representation clauses. - Bob