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,f584bf624aabe591 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2002-05-16 07:13:34 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!logbridge.uoregon.edu!paloalto-snh1.gtei.net!cambridge1-snf1.gtei.net!news.gtei.net!bos-service1.ext.raytheon.com!dfw-service2.ext.raytheon.com.POSTED!not-for-mail Message-ID: <3CE3BE86.C0CDC2A4@raytheon.com> From: Mark Johnson X-Mailer: Mozilla 4.76 [en] (Windows NT 5.0; U) X-Accept-Language: en MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: Signed integer to modular type conversion References: Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Date: Thu, 16 May 2002 09:13:26 -0500 NNTP-Posting-Host: 192.27.48.39 X-Complaints-To: news@ext.ray.com X-Trace: dfw-service2.ext.raytheon.com 1021558413 192.27.48.39 (Thu, 16 May 2002 09:13:33 CDT) NNTP-Posting-Date: Thu, 16 May 2002 09:13:33 CDT Organization: Raytheon Company Xref: archiver1.google.com comp.lang.ada:24198 Date: 2002-05-16T09:13:26-05:00 List-Id: "Grein, Christoph" wrote: > > From: Mark Johnson > > PS: I don't generally recommend this solution because many use it to > > excess. Try... > > with Unchecked_Conversion; > > function "+" is new Unchecked_Conversion(Integer, Mod_Type); > > Then your example assignment will be... > > Y := +X; > > The abuse comes from using this method for all sorts of type > > conversions, avoiding type safety, etc. > > Did you really observe much abuse? This affords so much more wording than a > simple type conversion, so why should someone abuse it? We develop large real time simulations of systems. I find examples all over the place in code that was developed by people skilled in the system they are simulating (and not so skilled in Ada). Most are pretty silly such as a converting between 16 and 32 bit values which a simple type conversion is adequate. When you go through code you see the Y := +X; you have to ask which "+" is it and why it is there. Also, we are rehosting software and switching compiler vendors. Using GNAT, we get good warnings about Unchecked_Conversion between different sizes and can evaluate if that is the "Right Choice". The three choices are zero extend, sign extend, or "unspecified value" - its the latter one which causes us the most problems and we generally have to fix code that might have worked OK on the old machine but will likely be broke on the new one. --Mark