comp.lang.ada
 help / color / mirror / Atom feed
From: "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de>
Subject: Re: Discriminants or Constructor Function for Limited Types
Date: Mon, 9 May 2022 14:31:33 +0200	[thread overview]
Message-ID: <t5b1j5$1l50$1@gioia.aioe.org> (raw)
In-Reply-To: nq0i7hhji09la6rujfl6vidqlag0ogb9ie@4ax.com

On 2022-05-09 14:05, Doctor Who wrote:
> On Mon, 9 May 2022 13:15:54 +0200, "Dmitry A. Kazakov"
> <mailbox@dmitry-kazakov.de> wrote:
> 
>> On 2022-05-09 12:19, Doctor Who wrote:
>>
>>> if you do a check before write there is no need to rise and propagate
>>> an exception.
>>
>> A bad idea.
>>
>> First it is an unnecessary overhead, because ultimately the check will
>> be repeated.
>>
>> Secondly it is technically impossible to do for a huge number of reasons:
>>
>> 1. Too complex to do. The modern hardware and software does a lot of
>> bookkeeping, indexing, replicating, compression, encryption, the stuff
>> almost impossible to estimate or predict in advance.
>>
>> 2. Unreliable due to racing conditions, volatile network states etc.
>>
>> 3. Very expensive, e.g. in the case of a networking file system or a
>> database and the asynchronous nature of modern I/O subsystems. When you
>> write a file you normally do not wait for the operation completion.
>> Actual writing continues asynchronously to your application going
>> through dozens of stacks, caches, buffers, buses. If that fails you will
>> learn that later in a consequent operation unless you explicitly call
>> Flush or equivalent. Checking the state is a synchronous operation that
>> would have hundred- to thousandfold performance penalty.
>>
>> 4. Just impossible like when dealing with a stream, a pipe line etc.
>>
>> As general design rules regarding exceptions consider:
>>
>> 1. Never use return code.
>>
>> 2. Never check anything non-trivial in advance.
> 
> we are talking about files, in a local disk right?

Yes, all this fully applies to local disks and filesystems.

Just look how writing an SSD works. I think you could get better chances 
with magnetic drums from 60's. (:-))

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

  reply	other threads:[~2022-05-09 12:31 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-05-04  9:02 Discriminants or Constructor Function for Limited Types R R
2022-05-04  9:40 ` Jeffrey R.Carter
2022-05-04  9:47 ` Dmitry A. Kazakov
2022-05-04 23:49   ` Randy Brukardt
2022-05-05  6:56     ` Dmitry A. Kazakov
2022-05-06  1:53       ` Randy Brukardt
2022-05-06  8:48         ` Dmitry A. Kazakov
2022-05-07  3:26           ` Randy Brukardt
2022-05-07 14:55             ` Dmitry A. Kazakov
2022-05-08  2:32               ` Randy Brukardt
2022-05-08  8:37                 ` Dmitry A. Kazakov
2022-05-08 17:19                   ` Doctor Who
2022-05-08 18:00                     ` Dmitry A. Kazakov
2022-05-08 18:07                       ` Doctor Who
2022-05-09  8:52                       ` Niklas Holsti
2022-05-09  9:45                         ` Dmitry A. Kazakov
2022-05-09 10:19                       ` Doctor Who
2022-05-09 11:15                         ` Dmitry A. Kazakov
2022-05-09 12:05                           ` Doctor Who
2022-05-09 12:31                             ` Dmitry A. Kazakov [this message]
2022-05-10  4:48                   ` Randy Brukardt
2022-05-10  6:18                     ` Dmitry A. Kazakov
2022-05-04 15:05 ` AdaMagica
2022-05-05  9:59 ` R R
replies disabled

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