comp.lang.ada
 help / color / mirror / Atom feed
From: Shark8 <onewingedshark@gmail.com>
Cc: mailbox@dmitry-kazakov.de
Subject: Re: Efficient Sequential Access to Arrays
Date: Thu, 26 Jul 2012 22:25:58 -0700 (PDT)
Date: 2012-07-26T22:25:58-07:00	[thread overview]
Message-ID: <802f6aec-a448-4a41-8320-fbdb5ffa7883@googlegroups.com> (raw)
In-Reply-To: <1qlao21lvhn4q.p95zkkqzzcqz$.dlg@40tude.net>

On Thursday, July 26, 2012 12:56:49 PM UTC-6, Dmitry A. Kazakov wrote:
> On Thu, 26 Jul 2012 10:40:32 -0700 (PDT), Shark8 wrote:
> 
> > On Thursday, July 26, 2012 7:46:04 AM UTC-6, Dmitry A. Kazakov wrote:
> >>
> >> Some would disagree, but IMO in a well-written Ada program you should never
> >> ever need 'Valid. Don't do Unchecked_Conversion with doubtful outcome.
> >> Don't use stream attributes for constrained types.
> > 
> > It might not be avoidable though; the presence of 'Valid however does let
> > you ensure that your [sub]typing assumptions are met.
> 
> These assumptions must be upheld per value construction.

Er, yes? Your value-construction procedure, which might be a stream-implementation, could use 'Input to ensure the data is valid, no? Then isn't the 'Read the value-construction?

{I'd actually place it into subprograms if we were talking about some sort of string-processing/basic-error-checking; in a little LISP-interpreter I was working on a while back I had it ensure balanced parens in reading a file/text via stream -- unbalanced means program-error, so throw an exception, balanced means I can continue processing and return the underlying structure for execution/operation.}

> > This might be especially true if you're importing data from some
> > third-party where the input-format doesn't specifically conform to your
> > expected-inputs. (This happens with disturbing frequency in handling
> > electronic medical records; usually because whoever started the record was
> > using a spreadsheet.)
> 
> Since this stuff is my primary occupation, a word of caution: don't do it
> this way. Always implement the protocol layers as defined, right from the
> representation data types (e.g. octet), up to Ada native ones. Never ever
> use representation clauses to cut corners.

Who's relying on representation clauses here? That's an assumption on your part that I don't think anyone here is making. Consider some value read in from a DB which is *always* supposed to be Positive; throwing a 'Valid check when loading the value isn't unreasonable: it keeps you from loading zero.

Many DBs don't support such range subtyping, so why is it "bad form" to ensure that such values, when read (ie value construction from the database) conform to the proper subtypes. (Though this might be done automatically on assignment from function if it falls outside the 'Range... I'll have to read up on when subtype constraints are applied.)



  reply	other threads:[~2012-07-27  5:27 UTC|newest]

Thread overview: 88+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-07-15 18:40 Efficient Sequential Access to Arrays Keean Schupke
2012-07-15 19:48 ` Dmitry A. Kazakov
2012-07-15 20:03   ` Keean Schupke
2012-07-15 20:56     ` Keean Schupke
2012-07-16 11:34       ` Jacob Sparre Andersen
2012-07-15 21:05     ` tmoran
2012-07-15 21:08       ` Keean Schupke
2012-07-16  1:19         ` tmoran
2012-07-15 21:44     ` Georg Bauhaus
2012-07-16  7:47     ` Dmitry A. Kazakov
2012-07-16 10:16       ` Keean Schupke
2012-07-16 14:57         ` Dmitry A. Kazakov
2012-07-16 16:39           ` Keean Schupke
2012-07-16 17:02             ` Georg Bauhaus
2012-07-16 18:48             ` Dmitry A. Kazakov
2012-07-16 19:12               ` Keean Schupke
2012-07-17  6:31                 ` Dmitry A. Kazakov
2012-07-17  6:50                   ` Georg Bauhaus
2012-07-17  8:42                     ` Dmitry A. Kazakov
2012-07-17  7:24                   ` Keean Schupke
2012-07-16 19:43             ` John B. Matthews
2012-07-16 20:44               ` Keean Schupke
2012-07-16 22:23             ` tmoran
2012-07-17  6:40               ` Keean Schupke
2012-07-17  9:01                 ` Dmitry A. Kazakov
2012-07-18  8:10                   ` Keean Schupke
2012-07-18 18:11                     ` tmoran
2012-07-19 10:41                       ` Keean Schupke
2012-07-19 11:18                         ` Georg Bauhaus
2012-07-19 19:58                           ` Keean Schupke
2012-07-21  8:24                             ` Keean Schupke
2012-07-21 11:52                               ` Georg Bauhaus
2012-07-21 16:14                                 ` Keean Schupke
2012-07-21 17:09                                   ` Keean Schupke
     [not found]                                   ` <i78m081tccmp078spmsei1l5vnj3k0kbkj@invalid.netcom.com>
2012-07-22 15:50                                     ` Keean Schupke
2012-07-22  5:13                               ` Shark8
2012-07-15 21:35   ` J-P. Rosen
2012-07-15 19:52 ` Shark8
2012-07-15 20:16   ` Keean Schupke
2012-07-15 21:33     ` Georg Bauhaus
2012-07-17 18:16 ` Florian Weimer
2012-07-22 10:01 ` robin.vowels
2012-07-30  6:31   ` Jacob Sparre Andersen
2012-07-30  7:16     ` Keean Schupke
2012-07-30  9:20     ` Georg Bauhaus
2012-07-30 14:04       ` Keean Schupke
2012-07-22 10:09 ` robin.vowels
2012-07-22 16:02   ` Keean Schupke
2012-07-22 16:21 ` Florian Weimer
2012-07-22 16:46   ` Keean Schupke
2012-07-22 18:41     ` Florian Weimer
2012-07-24  8:21       ` Keean Schupke
2012-07-22 17:34   ` Niklas Holsti
2012-07-22 18:21     ` Keean Schupke
2012-07-30 14:18       ` Jacob Sparre Andersen
2012-07-24 16:00     ` robin.vowels
2012-07-25  7:09       ` Niklas Holsti
2012-07-25  9:03         ` Keean Schupke
2012-07-26  0:15           ` Randy Brukardt
2012-07-26  8:38             ` Keean Schupke
2012-07-26 10:10               ` Brian Drummond
2012-07-26 12:32                 ` Keean Schupke
2012-07-26 13:46                   ` Dmitry A. Kazakov
2012-07-26 17:40                     ` Shark8
2012-07-26 18:56                       ` Dmitry A. Kazakov
2012-07-27  5:25                         ` Shark8 [this message]
2012-07-27  6:28                           ` Dmitry A. Kazakov
2012-07-27  7:01                             ` Vasiliy Molostov
2012-07-27  8:48                               ` Dmitry A. Kazakov
2012-07-27 12:01                                 ` Georg Bauhaus
2012-07-27 16:49                                 ` Vasiliy Molostov
2012-07-27 19:38                                   ` Dmitry A. Kazakov
2012-07-28  5:32                             ` Shark8
2012-07-28  7:37                               ` Dmitry A. Kazakov
2012-07-28 18:32                                 ` Shark8
     [not found]                     ` <6ov218tnkbqu3vpkuo4t77rd7de0a3aesf@invalid.netcom.com>
2012-07-26 18:49                       ` Dmitry A. Kazakov
     [not found]                         ` <86d31898ne39maimbl24knds7rf38qg7vc@invalid.netcom.com>
2012-07-27  6:45                           ` Dmitry A. Kazakov
2012-07-27  8:21                   ` Keean Schupke
2012-07-27  8:50                     ` Dmitry A. Kazakov
2012-07-27  9:17                       ` Keean Schupke
2013-02-25 21:18                     ` Eryndlia Mavourneen
2012-07-26 13:08               ` Georg Bauhaus
2012-07-26 19:37                 ` stefan-lucks
2012-07-26 19:21               ` stefan-lucks
2012-07-31  3:12               ` Randy Brukardt
2012-07-26  7:11           ` Markus Schöpflin
2012-07-26 14:47         ` Robin Vowels
2012-07-26 15:18           ` Martin
replies disabled

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