TEAM-ADA Archives

Team Ada: Ada Programming Language Advocacy

TEAM-ADA@LISTSERV.ACM.ORG

Options: Use Classic View

Use Monospaced Font
Show Text Part by Default
Condense Mail Headers

Topic: [<< First] [< Prev] [Next >] [Last >>]

Print Reply
Sender: "Team Ada: Ada Advocacy Issues (83 & 95)" <[log in to unmask]>
Date: Thu, 4 Feb 1999 09:18:27 -0600
Reply-To: Samuel Mize <[log in to unmask]>
From: Samuel Mize <[log in to unmask]>
Content-Transfer-Encoding: 7bit
In-Reply-To: <[log in to unmask]> from "Rick Duley" at Feb 4, 99 04:46:11 pm
Content-Type: text/plain; charset=US-ASCII
MIME-Version: 1.0
Parts/Attachments: text/plain (59 lines)
Rick Duley wrote:

> 1.   It doesn't appear to be possible to compile the declaration of an
> unconstrained type as either private or limited private.  I haven't been
> able to find a prohibition of this in the LRM.  Is this a compiler problem
> (GNAT 3.1)?

I can't cite ARM chapter/verse, but I can see that this can't be done.
The problem is that you could then try to declare a variable of the
private type, but there's no way to give it its array bounds.  For
instance:

    package A is
      type A_Type is private;
    private
      type A_Type is array (integer range <>) of Integer;
    end A;

    -----
    with A;
    procedure Uses_A is
      My_A_Type: A.A_Type; -- what are the array bounds?
    ...

One solution is to have the bounds (or just the upper bound) be
discriminants to the private type.  This will force you to use a
record type for the full view:

    package A is
        type A_Type (Count: Integer) is private;

    private
        type Int_Array is array (Integer range <>) of Integer;

        type A_Type (Count: integer) is record
           A_Field: Int_Array (1..Count);
        end record;
    end a;

You could also have A_Type be an access to objects of type
Int_Array.  That way you wouldn't need to have the array
bounds be part of the public view.

If this doesn't fill the bill, you may have to rethink your data
design.  I'm not sure how you intend to use a private but
unconstrained type.

For chapter and verse, I suspect you should be checking for references
about unconstrained or indefinite types.

I hope this helps.

Best,
Sam Mize

--
Samuel Mize -- [log in to unmask] (home email) -- Team Ada
Fight Spam: see http://www.cauce.org/ \\\ Smert Spamonam

ATOM RSS1 RSS2