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-Thread: a07f3367d7,ae8b13d4d815893c X-Google-Attributes: gida07f3367d7,public,usenet X-Google-NewGroupId: yes X-Google-Language: ENGLISH,ASCII Path: g2news2.google.com!postnews.google.com!g19g2000vbi.googlegroups.com!not-for-mail From: christoph.grein@eurocopter.com Newsgroups: comp.lang.ada Subject: Re: (Num_Types.Mod_4 range 1..8) ------->why not (1..8)? Date: Tue, 19 May 2009 01:04:47 -0700 (PDT) Organization: http://groups.google.com Message-ID: <22a71a88-38ff-428e-8cd6-85131244c4d5@g19g2000vbi.googlegroups.com> References: <0571282b-0ab8-4eee-941f-e9369f5b4518@x6g2000vbg.googlegroups.com> <4a11b8cb$0$32680$9b4e6d93@newsspool2.arcor-online.net> <6b5fe400-2564-4fc9-a5bf-f83d1e476345@q14g2000vbn.googlegroups.com> <4a11cae4$0$32667$9b4e6d93@newsspool2.arcor-online.net> <03cb75a1-3458-420e-9871-6f64f784c177@s38g2000prg.googlegroups.com> <201fbf41-65ed-4428-b814-ea0c4065e10e@v17g2000vbb.googlegroups.com> NNTP-Posting-Host: 80.156.44.178 Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Trace: posting.google.com 1242720287 16818 127.0.0.1 (19 May 2009 08:04:47 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Tue, 19 May 2009 08:04:47 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: g19g2000vbi.googlegroups.com; posting-host=80.156.44.178; posting-account=rmHyLAoAAADSQmMWJF0a_815Fdd96RDf User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322; .NET CLR 2.0.50727; InfoPath.1; .NET CLR 3.0.04506.30; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729),gzip(gfe),gzip(gfe) X-HTTP-Via: 1.1 webwasher (Webwasher 6.8.3.4555) Xref: g2news2.google.com comp.lang.ada:5933 Date: 2009-05-19T01:04:47-07:00 List-Id: On May 19, 9:47=A0am, Petter wrote: > For scalar types Checked_Conversion is a good idea: > > generic > =A0 =A0type Source is (<>); > =A0 =A0type Target is (<>); > > function Checked_Conversion (S : Source) return Target; > > with Ada.Unchecked_Conversion; > function Checked_Conversion (S : Source) return Target is > =A0 =A0function "+" is new Ada.Unchecked_Conversion (Source =3D> Source, > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 = =A0 =A0 =A0 =A0 =A0 =A0 =A0Target =3D> Target); Be careful, a lot can get wrong if the sizes of Source and Target are different. The 'Valid attribute is not enough.