comp.lang.ada
 help / color / mirror / Atom feed
From: "J-P. Rosen" <rosen@adalog.fr>
Subject: Re: General integer-types.
Date: Sun, 07 Apr 2013 10:45:59 +0200
Date: 2013-04-07T10:45:59+02:00	[thread overview]
Message-ID: <kjrbje$akp$1@dont-email.me> (raw)
In-Reply-To: <4a0e3b63-7139-4f03-bae2-35beca608bda@googlegroups.com>

Le 07/04/2013 03:45, Shark8 a écrit :
>     Generic
> 	Size : Positive;
>     Package SWF_Integer is
> 	Exp : Constant Positive := Size-1;
> 	
> 	-- For some reason adding the "New Long_Long_Integer" allows
> 	-- this to compile... but it might ignore the Size aspect.
> 	Type Signed is New Long_Long_Integer Range -2**Exp..2**Exp-1
> 	with Size => Size;
>         
>         -- This doesn't work at all; Size is not static.	
> 	Type Unsigned is Mod 0..2**Size
> 	with Size => Size;
> 	
>     End SWF_Integer;
> 
A type definition must be static, and a size aspect too. A generic
formal is never static, therefore you can't define a type from a generic
parameter. (but of course, a constraint needs not be static, this is why
it works as a derived type). But then, all instantiations will use the
same size as Long_Long_Integer, which is likely not what you want.

-- 
J-P. Rosen
Adalog
2 rue du Docteur Lombard, 92441 Issy-les-Moulineaux CEDEX
Tel: +33 1 45 29 21 52, Fax: +33 1 45 29 25 00
http://www.adalog.fr

  reply	other threads:[~2013-04-07  8:45 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-04-07  1:45 General integer-types Shark8
2013-04-07  8:45 ` J-P. Rosen [this message]
2013-04-07 14:29   ` Shark8
replies disabled

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