From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-0.9 required=5.0 tests=BAYES_00,FORGED_GMAIL_RCVD, FREEMAIL_FROM autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: 103376,56525db28240414a X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Received: by 10.66.85.71 with SMTP id f7mr216134paz.39.1343366879671; Thu, 26 Jul 2012 22:27:59 -0700 (PDT) Path: c10ni41686pbw.0!nntp.google.com!news1.google.com!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail From: Shark8 Newsgroups: comp.lang.ada Subject: Re: Efficient Sequential Access to Arrays Date: Thu, 26 Jul 2012 22:25:58 -0700 (PDT) Organization: http://groups.google.com Message-ID: <802f6aec-a448-4a41-8320-fbdb5ffa7883@googlegroups.com> References: <01983f1c-f842-4b1f-a180-bcef531dad4c@googlegroups.com> <87ipdf4vh6.fsf@mid.deneb.enyo.de> <4ce44d2d-d789-42a0-a6ed-035f7f8d58be@googlegroups.com> <1d20andzhb0rk.ytxhpkza8tky$.dlg@40tude.net> <1qlao21lvhn4q.p95zkkqzzcqz$.dlg@40tude.net> NNTP-Posting-Host: 69.20.190.126 Mime-Version: 1.0 X-Trace: posting.google.com 1343366879 27990 127.0.0.1 (27 Jul 2012 05:27:59 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Fri, 27 Jul 2012 05:27:59 +0000 (UTC) Cc: mailbox@dmitry-kazakov.de In-Reply-To: <1qlao21lvhn4q.p95zkkqzzcqz$.dlg@40tude.net> Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=69.20.190.126; posting-account=lJ3JNwoAAAAQfH3VV9vttJLkThaxtTfC User-Agent: G2/1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Date: 2012-07-26T22:25:58-07:00 List-Id: 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: >=20 > > 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. > >=20 > > It might not be avoidable though; the presence of 'Valid however does l= et > > you ensure that your [sub]typing assumptions are met. >=20 > These assumptions must be upheld per value construction. Er, yes? Your value-construction procedure, which might be a stream-impleme= ntation, 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 w= as working on a while back I had it ensure balanced parens in reading a fil= e/text via stream -- unbalanced means program-error, so throw an exception,= balanced means I can continue processing and return the underlying structu= re 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.) >=20 > 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 chec= k 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 ens= ure that such values, when read (ie value construction from the database) c= onform to the proper subtypes. (Though this might be done automatically on = assignment from function if it falls outside the 'Range... I'll have to rea= d up on when subtype constraints are applied.)