comp.lang.ada
 help / color / mirror / Atom feed
From: "Randy Brukardt" <randy@rrsoftware.com>
Subject: Re: Press Release - Ada 2012 Language Standard Approved by ISO
Date: Thu, 27 Dec 2012 15:54:59 -0600
Date: 2012-12-27T15:54:59-06:00	[thread overview]
Message-ID: <kbig3o$qnb$1@munin.nbi.dk> (raw)
In-Reply-To: kbi56i$plr$1@dont-email.me

"Jeffrey Carter" <spam.jrcarter.not@spam.not.acm.org> wrote in message 
news:kbi56i$plr$1@dont-email.me...
> On 12/27/2012 08:30 AM, Dmitry A. Kazakov wrote:
>>
>>
>> And a nice race condition coming with that! Never use File_Exists if you
>> can.
>
> Precisely. Multiple processes may access the file system at the same time. 
> The idea that you can check the precondition to an operation and have the 
> result still hold when you invoke the operation is only valid for 
> sequential activities; when you're using a concurrent language like Ada 
> then there are often cases when that's a race. The Get operation for a 
> concurrent, non-blocking queue has the precondition "not Is_Empty", but 
> between checking that and invoking Get another task may have changed the 
> state of the queue.

And not just tasks in your program, but processes from other programs 
running on the machine, programs from other machines accessing your file 
system, and of course, the wetware (you) running the computer can change the 
state of the file system.

Moreover, it's not just file system operations that behave this way. Almost 
any interactions with the underlying system have this property (memory 
management, networking, GUI, etc.). This was a major consideration for the 
design of Claw -- everything raises exceptions because the operation of the 
GUI is necessarily asynchonous WRT to your program: the wetware running the 
program can click on the 'x' and close a window while the program is 
referencing it. There is no sane way to stop that (you can block those 
operations for a while, but doing it for long makes the GUI unresponsive). 
You can only handle errors, you cannot prevent them beforehand.

Dmitry also touched on the fact that prechecking can be too expensive to use 
in common scenarios. For instance, End_of_File is about as costly as Get 
when using Text_IO. If your program reads single characters, you're doubling 
the I/O time if you pretest with End_of_File (and if you are reading large 
files in a tight loop, that can make a significant performance difference - 
especially as Text_IO is slow anyway).

                                     Randy.





  reply	other threads:[~2012-12-27 21:54 UTC|newest]

Thread overview: 66+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-12-18  7:45 Press Release - Ada 2012 Language Standard Approved by ISO Dirk Craeynest
2012-12-18 16:57 ` Robert A Duff
2012-12-18 21:12   ` Bill Findlay
2012-12-18 21:36     ` Jeffrey Carter
2012-12-18 21:57       ` Bill Findlay
2012-12-19  8:33     ` Dmitry A. Kazakov
2012-12-19  9:00       ` Georg Bauhaus
2012-12-19  9:19         ` Dmitry A. Kazakov
2012-12-19  9:21           ` Georg Bauhaus
2012-12-19  9:38             ` Dmitry A. Kazakov
2012-12-19 12:23               ` Georg Bauhaus
2012-12-19 14:34       ` Bill Findlay
2012-12-20  1:52       ` Randy Brukardt
2012-12-21  9:01         ` Dmitry A. Kazakov
2012-12-21 10:13           ` Georg Bauhaus
2012-12-21 10:34             ` Georg Bauhaus
2012-12-21 13:38             ` Dmitry A. Kazakov
2012-12-22  1:40           ` Randy Brukardt
2012-12-22  9:02             ` Dmitry A. Kazakov
2012-12-22 22:38               ` Georg Bauhaus
2012-12-23  8:08                 ` Dmitry A. Kazakov
2012-12-23 23:38                   ` Shark8
2012-12-24  2:44                     ` sbelmont700
2012-12-24  5:29                       ` Shark8
2012-12-25 21:51                       ` Florian Weimer
2012-12-27  1:00                         ` sbelmont700
2012-12-27  1:47                           ` Randy Brukardt
2012-12-27 14:29                             ` sbelmont700
2012-12-27 15:30                               ` Dmitry A. Kazakov
2012-12-27 18:48                                 ` Jeffrey Carter
2012-12-27 21:54                                   ` Randy Brukardt [this message]
2012-12-27 22:09                                     ` J-P. Rosen
2013-01-11 11:41                                     ` Yannick Duchêne (Hibou57)
2013-01-11 11:35                                   ` Yannick Duchêne (Hibou57)
2013-01-11 16:13                                     ` Jacob Sparre Andersen
2013-01-12  2:06                                       ` Randy Brukardt
2013-01-11 11:33                                 ` Yannick Duchêne (Hibou57)
2013-01-11 14:15                                   ` Dmitry A. Kazakov
2013-01-11 16:19                                 ` File_Exists (Was: Press Release - Ada 2012 Language Standard Approved by ISO) Jacob Sparre Andersen
2013-01-11 19:36                                   ` Yannick Duchêne (Hibou57)
2013-01-14  5:09                                     ` File_Exists Jacob Sparre Andersen
2013-01-12  7:55                                   ` File_Exists (Was: Press Release - Ada 2012 Language Standard Approved by ISO) Georg Bauhaus
2012-12-27 20:12                             ` compilers, was Re: Press Release - Ada 2012 Language Standard Approved by ISO tmoran
2012-12-27 20:54                               ` Shark8
2012-12-27 22:00                               ` Randy Brukardt
2012-12-27 10:05                           ` Dmitry A. Kazakov
2013-01-11 11:28                           ` Yannick Duchêne (Hibou57)
2013-01-11 14:21                             ` Dmitry A. Kazakov
2013-01-11 14:23                               ` Yannick Duchêne (Hibou57)
2012-12-24  6:44                   ` Yannick Duchêne (Hibou57)
2012-12-24  9:02                     ` Dmitry A. Kazakov
2012-12-24 11:13                       ` Yannick Duchêne (Hibou57)
2012-12-24 15:49                         ` Exception contracts for Ada? Was: " Peter C. Chapin
2012-12-24 16:34                           ` Dmitry A. Kazakov
2012-12-24 19:45                             ` Exception contracts for Ada? Peter C. Chapin
2012-12-25 11:09                               ` Dmitry A. Kazakov
2012-12-27  2:38                               ` Randy Brukardt
2012-12-27  2:16                           ` Exception contracts for Ada? Was: Re: Press Release - Ada 2012 Language Standard Approved by ISO Randy Brukardt
2012-12-27 15:03                             ` Peter C. Chapin
2012-12-27  1:17               ` Randy Brukardt
2013-01-11 17:10       ` Marius Amado-Alves
2012-12-20 21:55     ` Anh Vo
2012-12-21  1:04       ` Bill Findlay
2012-12-18 23:24   ` Randy Brukardt
2012-12-19  8:35     ` Georg Bauhaus
2012-12-19  9:03       ` Dmitry A. Kazakov
replies disabled

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