comp.lang.ada
 help / color / mirror / Atom feed
From: Marius Amado Alves <amado.alves@netcabo.pt>
To: comp.lang.ada@ada-france.org
Subject: Re: Problem with generic parameter
Date: Wed, 22 Jun 2005 12:58:12 +0100
Date: 2005-06-22T12:58:12+01:00	[thread overview]
Message-ID: <mailman.82.1119441536.17633.comp.lang.ada@ada-france.org> (raw)
In-Reply-To: <m2acli7kvd.fsf@hugin.crs4.it>

I think this is legal, so the compiler is buggy. But I find it an  
unlogical generic idiom, and probably the bug has passed unnoticed  
before for this reason. That is, nobody wrote this before. What I find  
unlogical is the Generic_Root.Child parameters. I would find it logical  
to represent the array type as an exported entity instead of a generic  
parameter.

generic
    type Indices is (<>);
package Generic_Root
    type Measurement is array (Indices) of Measurement;

On 22 Jun 2005, at 11:21, Jacob Sparre Andersen wrote:

> with Generic_Root;
> with Generic_Root.Child;
>
> procedure Demo is
>
>    type Scalar is digits 15;
>
>    package Measurements is
>       new Generic_Root (Scalar => Scalar);
>
>    type Measurement_Array is array (Positive range <>)
>      of Measurements.Measurement;
>
>    package Measurement_Text_IO is
>       new Measurements.Child (Indices           => Positive,
>                               Measurement_Array => Measurement_Array);
>
> begin
>    null;
> end Demo;
>
> generic
>
>    type Scalar is digits <>;
>
> package Generic_Root is
>
>     
> ----------------------------------------------------------------------- 
> ----
>    --  type Limit:
>
>    type Limit is (Below, Exact, Above, Undefined);
>
>     
> ----------------------------------------------------------------------- 
> ----
>    --  type Measurement:
>
>    type Measurement (As : Limit := Exact) is
>       record
>          case As is
>             when Below | Exact | Above =>
>                Value : Scalar;
>             when Undefined =>
>                null;
>          end case;
>       end record;
>
>     
> ----------------------------------------------------------------------- 
> ----
>
> end Generic_Root;
>
> with Ada.Text_IO;
>
> generic
>
>    type Indices is (<>);
>
>    type Measurement_Array is array (Indices range <>) of Measurement;
>
> package Generic_Root.Child is
>
> end Generic_Root.Child;




  parent reply	other threads:[~2005-06-22 11:58 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-06-22 10:21 Problem with generic parameter Jacob Sparre Andersen
2005-06-22 11:16 ` Martin Dowie
2005-06-22 11:58 ` Marius Amado Alves [this message]
2005-06-22 13:09   ` Jacob Sparre Andersen
2005-06-22 14:26     ` Marius Amado Alves
     [not found] ` <f6af3631a69872fe2f46258f86b08473@netcabo.pt>
2005-06-22 12:43   ` Marius Amado Alves
replies disabled

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