comp.lang.ada
 help / color / mirror / Atom feed
From: Mark Johnson <mark_h_johnson@raytheon.com>
Subject: Re: Signed integer to modular type conversion
Date: Thu, 16 May 2002 09:13:26 -0500
Date: 2002-05-16T09:13:26-05:00	[thread overview]
Message-ID: <3CE3BE86.C0CDC2A4@raytheon.com> (raw)
In-Reply-To: mailman.1021524187.24517.comp.lang.ada@ada.eu.org

"Grein, Christoph" wrote:
> 
> From: Mark Johnson <mark_h_johnson@raytheon.com>
> > 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



  reply	other threads:[~2002-05-16 14:13 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-05-16  4:39 Signed integer to modular type conversion Grein, Christoph
2002-05-16 14:13 ` Mark Johnson [this message]
  -- strict thread matches above, loose matches on Subject: below --
2002-05-15  5:43 Grein, Christoph
2002-05-15  2:53 Adam Beneschan
2002-05-15  3:34 ` Jim Rogers
2002-05-15 14:01 ` Mark Johnson
2002-05-16  0:02   ` Adam Beneschan
2002-05-16  2:26     ` Steven Deller
2002-05-16  9:53     ` Robert Dewar
2002-05-16 13:46       ` Steve Doiel
2002-05-16 14:00       ` Mark Johnson
2002-05-16 15:52       ` Adam Beneschan
2002-05-17  2:26         ` Robert Dewar
2002-05-17 16:44           ` Frank J. Lhota
2002-05-16 13:55     ` Mark Johnson
2002-05-15 19:12 ` Robert Dewar
2002-05-15 20:28 ` Adam Beneschan
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox