comp.lang.ada
 help / color / mirror / Atom feed
From: BRYAN@SU-SIERRA.ARPA (Doug Bryan)
Subject: Re: Mutually Recursive Data-Structures in ADA
Date: Thu, 19-Sep-85 01:38:45 EDT	[thread overview]
Date: Thu Sep 19 01:38:45 1985
Message-ID: <8509191758.AA23499@UCB-VAX.ARPA> (raw)
In-Reply-To: geoff%boulder.csnet@CSNET-RELAY.ARPA


Geoffrey,

Submitted for your consideration:

  ---------------------
  generic
    type File is limited private;
  package Item_Pac is
    type Item is limited private;

    function Get_File (Of_Item : Item) return File;
    -- other operations...
  private
    type Item is
      record
        F : File;
        -- other data
      end record;
  end Item_Pac;

  package body Item_Pac is
    ...
  end Item_Pac;
  ---------------------
  generic
    type Item is limited private;
  package Parameter_Pac is
    type Parameter is limited private;

    function Get_Item (Of_Parameter : Parameter) return Item;
    -- other operations...
  private
    type Parameter is 
      record
        I : Item;
        -- other data
      end record;
  end Parameter_Pac;

  package body Parameter_Pac is
    ...
  end Parameter_Pac;
  ---------------------
  with Item_Pac, Parameter_Pac;
  package File_Pac is
    type File is limited private;
    type Access_File is access File;

    package Items is new Item_Pac (File => Access_File);
    package Parameters is new Parameter_Pac (Item => Items.Item);

    function Get_Parameter (Of_File : File) return Parameters.Parameter;
    function Get_Parameter (Of_File : Access_File) return Parameters.Parameter;
    -- other operations...
  private
    type File is
      record
        P : Parameters.Parameter;
        -- other data
      end record;
  end File_Pac;

  package body File_Pac is
    ...
  end File_Pac;
  ------------------

Now the users need simply "with" File_Pac to get the operations on all
three abstract data types.  The types need not be limited.  We used
limited types to show that this method should work for any actual
implementations of the types.

what think you?

Doug Bryan            Geoff Mendal
bryan@su-sierra       Mendal%UMich-MTS.Mailnet@MIT-Multics.ARPA
Stanford U.           Lockheed Missiles & Space Company, Inc.

-------

       reply	other threads:[~1985-09-19  5:38 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <geoff%boulder.csnet@CSNET-RELAY.ARPA>
1985-09-19  5:38 ` Doug Bryan [this message]
1985-09-23 15:25   ` Mutually Recursive Data-Structures in ADA Geoffrey M. Clemm
1985-09-18  2:11 Geoffrey Clemm
1985-09-23 23:30 ` Frank Adams
replies disabled

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