comp.lang.ada
 help / color / mirror / Atom feed
From: enterpoop.mit.edu!snorkelwacker.mit.edu!stanford.edu!agate!spool.mu.edu!c aen!uvaarpa!software.org!smithd@ucbvax.Berkeley.EDU  (Doug Smith)
Subject: Re: I/O and the LRM
Date: 21 Dec 92 16:34:35 GMT	[thread overview]
Message-ID: <1992Dec21.163435.22675@software.org> (raw)

In article <206@hathor.CSS.GOV> jeffe@hathor.CSS.GOV (Jeff Etrick) writes:
> 
> 
>  The following is taken from the LRM:
> 
> >>function NAME(FILE : in FILE_TYPE) return STRING;
> 
> >>Returns a string which uniquely identifies the external file currently
> >>associated with the given file (and may thus be used in an OPEN
> >>operation).  If an environment allows alternative specifications of the
> >>name (for example, abbreviations), the string returned by the function
> >>should correspond to a full specification of the name.
> 
> >>The exception STATUS_ERROR is raised if the given file is not open.
> 
> 
>  I have used the function successfully many times to get the external
> name of a currently opened file but what I don't understand is the
> comment about it being used in an open statement. Why would I want to use
> this statement in an open since the file must already be opened or
> STATUS_ERROR will be raised.
> 
> Thanks for the help,
> 
> Jeff

It will take a while to answer your question...

In one application, I found that a temporary file would be useful.
When I discovered that Ada allowed you to create temporary files,
I quickly used this new-found expertise:

    Create (Temp, Out_File);

Of course, my next lesson was quite disheartening:

    -- Much information written to file.
    ...
       Temp_Name : constant String := Name (Temp);
    begin
       Close (Temp); -- Temp is deleted from system!
       Send_Name_To_Sub_Process (Temp_Name);

Yes, as soon as the temporary file is closed, it
was deleted--and not by the system.  I could not use
temporary files to pass data to a subprocess.
(Will this behavior still be allowed in Ada9X?)
AI-00046/06-ra-WJ states:
    1)  An implementation is allowed to delete a temporary file
        immediately after closing it.

Yet, the feature that was so beneficial was that a system
dependent name was available!  So now:

      Create (Temp, Out_File)
      declare
         Temp_Name : constant String := Name (Temp);
      begin
         Close (Temp); -- Temp is deleted from system!
         ...
         Create (Temp, Out_File, Get_Temp_Name);

         -- Much information written to file.

         Close (Temp); -- Temp not deleted!
         Send_Name_To_Sub_Process (Temp_Name);

THEN, THE OTHER PROCESS CAN PERFORM AN OPEN USING THE
STRING FROM A NAME FUNCTION.  Yes, this is convoluted
and not necessarily applicable to a single Ada program
which could be redesigned to use the RESET feature--
but you asked for it!

However, this is still a system dependent feature, because
the same AI states:

    2)  The NAME function is allowed to raise USE_ERROR if
        its argument is associated with an external file
        that has no name, in particular, a temporary file.

Oh, well.

Doug Smith
smithd@software.org

             reply	other threads:[~1992-12-21 16:34 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1992-12-21 16:34 enterpoop.mit.edu!snorkelwacker.mit.edu!stanford.edu!agate!spool.mu.edu!c [this message]
  -- strict thread matches above, loose matches on Subject: below --
1992-12-22 15:09 I/O and the LRM David Emery
1992-12-21 18:20 paladin.american.edu!darwin.sura.net!aplcen.apl.jhu.edu!ddsdx2.jhuapl.edu
1992-12-17 16:30 Robert I. Eachus
1992-12-17 13:25 Jeff Etrick
replies disabled

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