From: Maciej Sobczak <see.my.homepage@gmail.com>
Subject: Re: Files and controlled types
Date: Sun, 9 Mar 2008 06:27:48 -0700 (PDT)
Date: 2008-03-09T06:27:48-07:00 [thread overview]
Message-ID: <e1019237-f828-4db1-80d8-666ed82c8858@n75g2000hsh.googlegroups.com> (raw)
In-Reply-To: BAIAj.14527$TT4.474@attbi_s22
On 9 Mar, 04:12, "Jeffrey R. Carter" <spam.jrcarter....@spam.acm.org>
wrote:
> > File types are not Controlled.
> > What is the rationale for this?
>
> What makes you think they're not controlled.
a) AARM
b) trivial test
> The ARM only gives the public view,
> which is limited private; there's nothing to prevent the full view from being
> controlled.
There is nothing that mandates it and therefore I have to assume it is
not done. This is actually what I see in tests.
> In addition, the descriptions of Ada.Sequential_IO, Ada.Direct_IO,
> and Ada.Text_IO all include the language "The type File_Type needs finalization
> (see 7.6)".
This is very good - I haven't notice it.
It is very good, because then instead of broken library definition we
can talk about implementation bugs - these are easier to fix.
My little test follows:
with Ada.Text_IO;
procedure A is
procedure New_File (I : in Integer) is
Name : String := "temp/" & Integer'Image (I) & ".txt";
F : Ada.Text_IO.File_Type;
begin
Ada.Text_IO.Put_Line ("Opening " & Name);
Ada.Text_IO.Create (F, Ada.Text_IO.Out_File, Name);
-- Ada.Text_IO.Close (F);
end New_File;
begin
for I in -1000 .. -1 loop
New_File (I);
end loop;
end;
This program creates 1000 files with names "temp/-1000.txt",
"temp/-999.txt", etc. (I use negative counters because I don't want to
waste my time with that useless space in front of the image of
positive integer value).
If the File_Type has finalization, then this program is expected to
finish correctly without the Close call (uncommented above).
On my computer it fails with USE_ERROR after creating 253 files. If we
add the three standard I/O streams, we get a reasonable assumption
that the program has hit an implementation limit (256?) of open file
descriptors.
If I uncomment the Close call, the program properly creates full 1000
set of files.
I expect Close to be called automatically as part of finalization.
So - is it the implementation (GNAT) bug?
Or maybe the finalization is concerned with memory management only
(buffers, etc.) and not with external resources? In that case I
consider it a bug in AARM.
--
Maciej Sobczak * www.msobczak.com * www.inspirel.com
next prev parent reply other threads:[~2008-03-09 13:27 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-03-08 21:22 Files and controlled types Maciej Sobczak
2008-03-08 21:56 ` gpriv
2008-03-09 3:12 ` Jeffrey R. Carter
2008-03-09 13:27 ` Maciej Sobczak [this message]
2008-03-10 15:37 ` Adam Beneschan
2008-03-10 21:45 ` Maciej Sobczak
2008-03-09 16:39 ` gpriv
2008-03-10 15:28 ` Eric Hughes
2008-03-10 22:45 ` Robert A Duff
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox