comp.lang.ada
 help / color / mirror / Atom feed
* procedure Make_File_Gone (Name : in String);
@ 2011-07-20  6:04 tmoran
  2011-07-20  7:03 ` Oliver Kleinke
                   ` (6 more replies)
  0 siblings, 7 replies; 16+ messages in thread
From: tmoran @ 2011-07-20  6:04 UTC (permalink / raw)


What's a good name for a procedure that does an
Ada.Directories.Delete_File if the file exists, and silently returns if
the file is already gone.



^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: procedure Make_File_Gone (Name : in String);
  2011-07-20  6:04 procedure Make_File_Gone (Name : in String); tmoran
@ 2011-07-20  7:03 ` Oliver Kleinke
  2011-07-20  7:12 ` Niklas Holsti
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 16+ messages in thread
From: Oliver Kleinke @ 2011-07-20  7:03 UTC (permalink / raw)


Am Wed, 20 Jul 2011 06:04:18 +0000 (UTC)
schrieb tmoran@acm.org:

> What's a good name for a procedure that does an
> Ada.Directories.Delete_File if the file exists, and silently returns
> if the file is already gone.

Unlink, Remove, Delete, ... Silent_Unlink, ... or maybe Unlink (Silent
=> True), ...



^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: procedure Make_File_Gone (Name : in String);
  2011-07-20  6:04 procedure Make_File_Gone (Name : in String); tmoran
  2011-07-20  7:03 ` Oliver Kleinke
@ 2011-07-20  7:12 ` Niklas Holsti
  2011-07-20  7:34 ` Martin
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 16+ messages in thread
From: Niklas Holsti @ 2011-07-20  7:12 UTC (permalink / raw)


tmoran@acm.org wrote:
> What's a good name for a procedure that does an
> Ada.Directories.Delete_File if the file exists, and silently returns if
> the file is already gone.

Difficult question. In a multi-process system the procedure cannot, of 
course, guarantee that the file does not (again) exist when the 
procedure returns, so "Make_File_Gone" promises too much.

Perhaps Delete_Possibly_Existing_File.

-- 
Niklas Holsti
Tidorum Ltd
niklas holsti tidorum fi
       .      @       .



^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: procedure Make_File_Gone (Name : in String);
  2011-07-20  6:04 procedure Make_File_Gone (Name : in String); tmoran
  2011-07-20  7:03 ` Oliver Kleinke
  2011-07-20  7:12 ` Niklas Holsti
@ 2011-07-20  7:34 ` Martin
  2011-07-20 18:02 ` Jeffrey Carter
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 16+ messages in thread
From: Martin @ 2011-07-20  7:34 UTC (permalink / raw)


On Jul 20, 7:04 am, tmo...@acm.org wrote:
> What's a good name for a procedure that does an
> Ada.Directories.Delete_File if the file exists, and silently returns if
> the file is already gone.

Delete_File_If_Present?

-- Martin



^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: procedure Make_File_Gone (Name : in String);
  2011-07-20  6:04 procedure Make_File_Gone (Name : in String); tmoran
                   ` (2 preceding siblings ...)
  2011-07-20  7:34 ` Martin
@ 2011-07-20 18:02 ` Jeffrey Carter
  2011-07-21  7:56 ` Stephen Leake
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 16+ messages in thread
From: Jeffrey Carter @ 2011-07-20 18:02 UTC (permalink / raw)


On 07/19/2011 11:04 PM, tmoran@acm.org wrote:
> What's a good name for a procedure that does an
> Ada.Directories.Delete_File if the file exists, and silently returns if
> the file is already gone.

Delete.

-- 
Jeff Carter
"He didn't get that nose from playing ping-pong."
Never Give a Sucker an Even Break
110



^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: procedure Make_File_Gone (Name : in String);
  2011-07-20  6:04 procedure Make_File_Gone (Name : in String); tmoran
                   ` (3 preceding siblings ...)
  2011-07-20 18:02 ` Jeffrey Carter
@ 2011-07-21  7:56 ` Stephen Leake
  2011-07-22 23:44 ` Randy Brukardt
  2011-07-25 17:44 ` marius63
  6 siblings, 0 replies; 16+ messages in thread
From: Stephen Leake @ 2011-07-21  7:56 UTC (permalink / raw)


tmoran@acm.org writes:

> What's a good name for a procedure that does an
> Ada.Directories.Delete_File if the file exists, and silently returns if
> the file is already gone.

Delete_File.

I'm assuming you are declaring this in a package that is not
Ada.Directories, so overloading is perfectly appropriate.

The detailed semantics are in the comments, not the name.

-- 
-- Stephe



^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: procedure Make_File_Gone (Name : in String);
  2011-07-20  6:04 procedure Make_File_Gone (Name : in String); tmoran
                   ` (4 preceding siblings ...)
  2011-07-21  7:56 ` Stephen Leake
@ 2011-07-22 23:44 ` Randy Brukardt
  2011-07-23  2:16   ` tmoran
  2011-07-25 17:44 ` marius63
  6 siblings, 1 reply; 16+ messages in thread
From: Randy Brukardt @ 2011-07-22 23:44 UTC (permalink / raw)


<tmoran@acm.org> wrote in message news:j05r52$1h8$1@speranza.aioe.org...
> What's a good name for a procedure that does an
> Ada.Directories.Delete_File if the file exists, and silently returns if
> the file is already gone.

I'm of course partial to Purge for this use. :-)

[Background to the uninitiated: I had suggested to Tom and other Janus/Ada 
customers that they consider using Ada.Directories operations rather than 
the implementation-defined ones in Ada.Text_IO.Extensions as those are more 
portable; specifically replacing Ada.Text_IO.Extensions.Purge with 
Ada.Directories.Delete_File. Tom had followed that advice, except that it 
was causing random failures to his application -- which eventually turned 
out to be caused by the different behavior of Purge (do nothing) and 
Delete_File (raise an exception) if the file does not exist.]

                                         Randy.





^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: procedure Make_File_Gone (Name : in String);
  2011-07-22 23:44 ` Randy Brukardt
@ 2011-07-23  2:16   ` tmoran
  2011-07-23 14:55     ` Robert A Duff
  0 siblings, 1 reply; 16+ messages in thread
From: tmoran @ 2011-07-23  2:16 UTC (permalink / raw)


> I'm of course partial to Purge for this use. :-)

Another verb.  Both the phrase Delete_File and the word Purge say "go
do something" and they leave unclear what to do if you can't do the
action. I'd like to concisely make clear the post condition I'm trying
to achieve - in this case, the absence of a file of the given name.
Ideally this should be clear from the procedure name without having
to look in the ARM or depend on a comment of uncertain modernity.

And yes, there could be a race where someone created a new file of that
name immediately afterward, but avoiding such races is part of the
higher level design.



^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: procedure Make_File_Gone (Name : in String);
  2011-07-23  2:16   ` tmoran
@ 2011-07-23 14:55     ` Robert A Duff
  2011-07-23 19:05       ` tmoran
  0 siblings, 1 reply; 16+ messages in thread
From: Robert A Duff @ 2011-07-23 14:55 UTC (permalink / raw)


tmoran@acm.org writes:

>> I'm of course partial to Purge for this use. :-)
>
> Another verb.  Both the phrase Delete_File and the word Purge say "go
> do something" and they leave unclear what to do if you can't do the
> action. I'd like to concisely make clear the post condition I'm trying
> to achieve - in this case, the absence of a file of the given name.

I think you mean precondition.  The postcondition of the two is
the same -- the file isn't there.

I think distinguishing Delete_File and Delete would be confusing.
How would you remember which is which?

I'd say Delete_File should raise an exception if the file doesn't
exist, and Maybe_Delete_File should silently do nothing in that case.

> Ideally this should be clear from the procedure name without having
> to look in the ARM or depend on a comment of uncertain modernity.
>
> And yes, there could be a race where someone created a new file of that
> name immediately afterward, but avoiding such races is part of the
> higher level design.

Sure, that's true of pretty-much all file operations.

- Bob



^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: procedure Make_File_Gone (Name : in String);
  2011-07-23 14:55     ` Robert A Duff
@ 2011-07-23 19:05       ` tmoran
  2011-07-23 20:23         ` Dmitry A. Kazakov
  0 siblings, 1 reply; 16+ messages in thread
From: tmoran @ 2011-07-23 19:05 UTC (permalink / raw)


> The postcondition of the two is the same -- the file isn't there.

  I understand a postcondition to be true just after execution of
something.  The postcondition for an execution of
Ada_Directories.Delete_File is

"(the file isn't there and a Name_Error may or may not have been raised),
or a Use_Error has been raised"

I want a routine where the postcondition is

"the file isn't there, or a Use_Error has been raised"

(In my programming a Use_Error is exceptional, but trying to ensure
that a certain file no longer exists is not all that unusual.)

I'm looking for a good name for such a routine, where "good" means
short and clear to a maintenance programmer scanning the code.  Perhaps
English doesn't have a nice way of making such an imperative->declarative
phrase.



^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: procedure Make_File_Gone (Name : in String);
  2011-07-23 19:05       ` tmoran
@ 2011-07-23 20:23         ` Dmitry A. Kazakov
  2011-07-23 21:08           ` Simon Wright
  0 siblings, 1 reply; 16+ messages in thread
From: Dmitry A. Kazakov @ 2011-07-23 20:23 UTC (permalink / raw)


On Sat, 23 Jul 2011 19:05:02 +0000 (UTC), tmoran@acm.org wrote:

> I'm looking for a good name for such a routine, where "good" means
> short and clear to a maintenance programmer scanning the code.  Perhaps
> English doesn't have a nice way of making such an imperative->declarative
> phrase.

   procedure Delete_File (File : String; Existing : Boolean := True);

-- 
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de



^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: procedure Make_File_Gone (Name : in String);
  2011-07-23 20:23         ` Dmitry A. Kazakov
@ 2011-07-23 21:08           ` Simon Wright
  2011-07-25 15:49             ` Adam Beneschan
  0 siblings, 1 reply; 16+ messages in thread
From: Simon Wright @ 2011-07-23 21:08 UTC (permalink / raw)


"Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de> writes:

> On Sat, 23 Jul 2011 19:05:02 +0000 (UTC), tmoran@acm.org wrote:
>
>> I'm looking for a good name for such a routine, where "good" means
>> short and clear to a maintenance programmer scanning the code.  Perhaps
>> English doesn't have a nice way of making such an imperative->declarative
>> phrase.
>
>    procedure Delete_File (File : String; Existing : Boolean := True);

   procedure Delete_File (File : String; 
                          Only_If_Existing : Boolean := True);




^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: procedure Make_File_Gone (Name : in String);
  2011-07-23 21:08           ` Simon Wright
@ 2011-07-25 15:49             ` Adam Beneschan
  2011-07-25 17:28               ` Simon Wright
  0 siblings, 1 reply; 16+ messages in thread
From: Adam Beneschan @ 2011-07-25 15:49 UTC (permalink / raw)


On Jul 23, 2:08 pm, Simon Wright <si...@pushface.org> wrote:
> "Dmitry A. Kazakov" <mail...@dmitry-kazakov.de> writes:
>
> > On Sat, 23 Jul 2011 19:05:02 +0000 (UTC), tmo...@acm.org wrote:
>
> >> I'm looking for a good name for such a routine, where "good" means
> >> short and clear to a maintenance programmer scanning the code.  Perhaps
> >> English doesn't have a nice way of making such an imperative->declarative
> >> phrase.
>
> >    procedure Delete_File (File : String; Existing : Boolean := True);
>
>    procedure Delete_File (File : String;
>                           Only_If_Existing : Boolean := True);

Or you could go the other way:

   procedure Delete_File (File : String;
                          OK_If_File_Doesnt_Exist : Boolean := False);

The parameter name is clunky.  Still, I think I'd slightly prefer
something along those lines because I tried to read a call that looks
like this:

   Delete_File (F, Only_If_Existing => False);

I'd be scratching my head trying to figure out what it meant.  It's
probably better to use names that mean nothing:

   Delete_File (F, Glarfspoogl => False);

than to use names that look like they're intended to convey meaning
but actually are just confusing.  The former at least will force
readers to go back and look at the documentation.  (I'm only half-
serious here.  I don't recommending using ridiculous names like
Glarfspoogl.)

                              -- Adam




^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: procedure Make_File_Gone (Name : in String);
  2011-07-25 15:49             ` Adam Beneschan
@ 2011-07-25 17:28               ` Simon Wright
  0 siblings, 0 replies; 16+ messages in thread
From: Simon Wright @ 2011-07-25 17:28 UTC (permalink / raw)


Adam Beneschan <adam@irvine.com> writes:

> On Jul 23, 2:08 pm, Simon Wright <si...@pushface.org> wrote:
>> "Dmitry A. Kazakov" <mail...@dmitry-kazakov.de> writes:
>>
>> > On Sat, 23 Jul 2011 19:05:02 +0000 (UTC), tmo...@acm.org wrote:
>>
>> >> I'm looking for a good name for such a routine, where "good" means
>> >> short and clear to a maintenance programmer scanning the code.  Perhaps
>> >> English doesn't have a nice way of making such an imperative->declarative
>> >> phrase.
>>
>> >    procedure Delete_File (File : String; Existing : Boolean := True);
>>
>>    procedure Delete_File (File : String;
>>                           Only_If_Existing : Boolean := True);
>
> Or you could go the other way:
>
>    procedure Delete_File (File : String;
>                           OK_If_File_Doesnt_Exist : Boolean := False);
>
> The parameter name is clunky.  Still, I think I'd slightly prefer
> something along those lines because I tried to read a call that looks
> like this:
>
>    Delete_File (F, Only_If_Existing => False);
>
> I'd be scratching my head trying to figure out what it meant.  It's
> probably better to use names that mean nothing:
>
>    Delete_File (F, Glarfspoogl => False);
>
> than to use names that look like they're intended to convey meaning
> but actually are just confusing.  The former at least will force
> readers to go back and look at the documentation.  (I'm only half-
> serious here.  I don't recommending using ridiculous names like
> Glarfspoogl.)

I take your point.

  With_Exception_If_Not_Found : Boolean := True

(we could argue this one for a long time if we had nothing better to
do!)




^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: procedure Make_File_Gone (Name : in String);
  2011-07-20  6:04 procedure Make_File_Gone (Name : in String); tmoran
                   ` (5 preceding siblings ...)
  2011-07-22 23:44 ` Randy Brukardt
@ 2011-07-25 17:44 ` marius63
  2011-07-27 15:38   ` tmoran
  6 siblings, 1 reply; 16+ messages in thread
From: marius63 @ 2011-07-25 17:44 UTC (permalink / raw)


On Jul 20, 7:04 am, tmo...@acm.org wrote:
> What's a good name for a procedure that does an
> Ada.Directories.Delete_File if the file exists, and silently returns if
> the file is already gone.

I have seen "ensure" used around lately. So, Ensure_Deleted.

OTOH, Ada parlance has "unchecked". So, Unchecked_Delete_File.



^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: procedure Make_File_Gone (Name : in String);
  2011-07-25 17:44 ` marius63
@ 2011-07-27 15:38   ` tmoran
  0 siblings, 0 replies; 16+ messages in thread
From: tmoran @ 2011-07-27 15:38 UTC (permalink / raw)


> I have seen "ensure" used around lately. So, Ensure_Deleted.

I like it.  Thanks.



^ permalink raw reply	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2011-07-27 15:38 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-07-20  6:04 procedure Make_File_Gone (Name : in String); tmoran
2011-07-20  7:03 ` Oliver Kleinke
2011-07-20  7:12 ` Niklas Holsti
2011-07-20  7:34 ` Martin
2011-07-20 18:02 ` Jeffrey Carter
2011-07-21  7:56 ` Stephen Leake
2011-07-22 23:44 ` Randy Brukardt
2011-07-23  2:16   ` tmoran
2011-07-23 14:55     ` Robert A Duff
2011-07-23 19:05       ` tmoran
2011-07-23 20:23         ` Dmitry A. Kazakov
2011-07-23 21:08           ` Simon Wright
2011-07-25 15:49             ` Adam Beneschan
2011-07-25 17:28               ` Simon Wright
2011-07-25 17:44 ` marius63
2011-07-27 15:38   ` tmoran

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