comp.lang.ada
 help / color / mirror / Atom feed
From: Ludovic Brenta <ludovic@ludovic-brenta.org>
Subject: Re: newbie problem
Date: Wed, 13 May 2009 08:44:34 -0700 (PDT)
Date: 2009-05-13T08:44:34-07:00	[thread overview]
Message-ID: <8199f78c-21e8-42dc-b7f6-d6a3b2f13bf5@g20g2000vba.googlegroups.com> (raw)
In-Reply-To: 4a0ad646$0$2854$ba620e4c@news.skynet.be

Olivier Scalbert wrote on comp.lang.ada:
> Problem 1: it does not compile !
> adasound.ads:23:10: completion of nonlimited type cannot be limited
> adasound.ads:23:10: component "File_Type" of type "Als_File_T" has
> limited type

File_Type is of a limited type; any type containing it must therefore
also be limited.  Martin and Adam explained that very well.  My
preferred solution would be to make Als_File_T limited, too, since it
also represents a file.

> Problem 2: how to avoid the first "with Sequential_Io;" ?

Solution 1, as explaines by Martin: private with Ada.Sequential_IO;
this assumes that the presence of the with clause is only a minor
problem.  I would tend to agree that this problem is minor.

Solution 2: If you absolutely want to hide the with clause, you can
move it to the body of your package by making Als_File_T completely
opaque, like so:

package Adasound is
   type Als_File_T is private; -- or limited private
private
   type Internal_T;
   type Als_File_T is access Internal_T;
end Adasound;

with Ada.Sequential_IO;
package body Adasound is
   package Stereo_Amplitude_IO is new Sequential_Io
(Stereo_Amplitude_T);
   type Internal_T is limited record
      File_Type : Stereo_Amplitude_IO.File_Type;
   end record;
end Adasound;

The drawback of making Als_File_T opaque is that not even child
packages of Adasound can see the internals of the type.  This may be a
problem if you want to write unit tests (which are often child
packages or child procedures of the unit under test).

--
Ludovic Brenta.



  parent reply	other threads:[~2009-05-13 15:44 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-05-13 14:16 newbie problem Olivier Scalbert
2009-05-13 14:54 ` Martin
2009-05-13 15:20   ` Olivier Scalbert
2009-05-13 15:14 ` Adam Beneschan
2009-05-13 15:54   ` Olivier Scalbert
2009-05-13 15:44 ` Ludovic Brenta [this message]
2009-05-13 16:03   ` Olivier Scalbert
2009-05-13 18:00 ` Olivier Scalbert
2009-05-13 18:51   ` Martin
2009-05-13 19:45     ` sjw
2009-05-13 19:48     ` Olivier Scalbert
2009-05-14 19:41       ` sjw
2009-05-15  5:02         ` Olivier Scalbert
2009-05-15  8:05         ` Jean-Pierre Rosen
2009-05-18 10:23         ` Olivier Scalbert
2009-05-18 10:48           ` Martin
2009-05-18 10:54             ` Olivier Scalbert
2009-05-18 10:52           ` Ludovic Brenta
2009-05-18 11:09             ` Olivier Scalbert
2009-05-14 22:39       ` Jeffrey R. Carter
2009-05-14  2:59 ` anon
  -- strict thread matches above, loose matches on Subject: below --
1998-12-05  0:00 Graeme Wallace
1998-12-04  0:00 ` David Botton
1998-12-04  0:00 ` Gautier.DeMontmollin
1998-12-04  0:00 ` Mats Weber
1998-12-05  0:00   ` Matthew Heaney
1998-12-04  0:00 ` Marin David Condic
1998-12-04  0:00 ` Simon Bracken
1998-12-04  0:00   ` Marin David Condic
1998-12-05  0:00 ` Matthew Heaney
1998-12-07  0:00 ` Jeff Carter
replies disabled

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