comp.lang.ada
 help / color / mirror / Atom feed
From: christoph.grein@eurocopter.com
Subject: Re: (Num_Types.Mod_4 range 1..8) ------->why not (1..8)?
Date: Tue, 19 May 2009 01:04:47 -0700 (PDT)
Date: 2009-05-19T01:04:47-07:00	[thread overview]
Message-ID: <22a71a88-38ff-428e-8cd6-85131244c4d5@g19g2000vbi.googlegroups.com> (raw)
In-Reply-To: 201fbf41-65ed-4428-b814-ea0c4065e10e@v17g2000vbb.googlegroups.com

On May 19, 9:47 am, Petter <petter_frykl...@hotmail.com> wrote:
> For scalar types Checked_Conversion is a good idea:
>
> generic
>    type Source is (<>);
>    type Target is (<>);
>
> function Checked_Conversion (S : Source) return Target;
>
> with Ada.Unchecked_Conversion;
> function Checked_Conversion (S : Source) return Target is
>    function "+" is new Ada.Unchecked_Conversion (Source => Source,
>                                                  Target => Target);

Be careful, a lot can get wrong if the sizes of Source and Target are
different. The 'Valid attribute is not enough.



  reply	other threads:[~2009-05-19  8:04 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-05-18 19:19 (Num_Types.Mod_4 range 1..8) ------->why not (1..8)? convergence82
2009-05-18 19:36 ` Georg Bauhaus
2009-05-18 19:58   ` convergence82
2009-05-18 20:50     ` Adam Beneschan
2009-05-18 20:53     ` Georg Bauhaus
2009-05-18 21:12       ` convergence82
2009-05-18 21:24       ` Adam Beneschan
2009-05-19  6:26         ` christoph.grein
2009-05-19  7:47           ` Petter
2009-05-19  8:04             ` christoph.grein [this message]
2009-05-19 13:13               ` Petter
2009-05-19 15:27                 ` Georg Bauhaus
2009-05-19 17:53           ` Adam Beneschan
2009-05-18 19:49 ` Robert A Duff
replies disabled

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