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=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,1fa85f3df5841ae1 X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news3.google.com!news.glorb.com!border1.nntp.dca.giganews.com!nntp.giganews.com!local01.nntp.dca.giganews.com!nntp.megapath.net!news.megapath.net.POSTED!not-for-mail NNTP-Posting-Date: Fri, 29 Apr 2005 15:23:57 -0500 From: "Randy Brukardt" Newsgroups: comp.lang.ada References: <426e4c2b$0$7515$9b4e6d93@newsread2.arcor-online.net> <0uYbe.542$BE3.229@newsread2.news.pas.earthlink.net> <1wjh6qsazg3rg$.lupowyuqu0tw$.dlg@40tude.net> Subject: Re: Ada.Containers.Vectors - querying multiple elements Date: Fri, 29 Apr 2005 15:26:31 -0500 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 5.50.4927.1200 X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4927.1200 Message-ID: NNTP-Posting-Host: 64.32.209.38 X-Trace: sv3-ioL92m3wtGzkifY0UR7rENwVcAigdqGqNCdp+PSTdwQnxg6oyjiQ66kpqtb5Jn24v1C8q3bJWXxP+1a!Js9/vFRD5dQmVnuZzn0O7hGg+TnPC0lRNdoBMrIbKumecajUMxmxkksLB4YUXRRLem6zGz63LmHL X-Complaints-To: abuse@megapath.net X-DMCA-Complaints-To: abuse@megapath.net X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your complaint properly X-Postfilter: 1.3.32 Xref: g2news1.google.com comp.lang.ada:10832 Date: 2005-04-29T15:26:31-05:00 List-Id: "Dmitry A. Kazakov" wrote in message news:1wjh6qsazg3rg$.lupowyuqu0tw$.dlg@40tude.net... ... > I wonder if introducing ranges as a type class could mend this. Provided a > fictitious attribute Enum'Range (0) would return a null-length range, one > could then create empty arrays without referencing to any concrete index > bounds. But then Obj'First and Obj'Last could potentially raise > Constraint_Error, which might appear unpleasant but perfectly consistent. > Could there be a distributed overhead in the implementations of 'First and > 'Last then? Yes, there would be a distributed overhead. For Janus/Ada (the only compiler for which I can speak definitively), in the general case array bounds are stored in a descriptor record, along with a dimension length and a pointer to the data. The dimension length is really redundant; I don't think most compilers store it separately. In order to be able to represent an array as you say, all compilers would have to store the dimension length and presumably a bit mask to specify which bounds are invalid and raise C_E if explicitly touched. And of course all references to 'First and 'Last would have to check the bit mask. Not too expensive, but certainly a significant change to compilers and some additional overhead. Array indexing in the general case subtracts 'First from the calculated value, so I don't think it would make sense to allow 'First to be an invalid value - at least not unless the length of the array was 0 (in which case it doesn't matter). But adding overhead to array indexing operations is not going to win anyone friends. :-) More seriously, I think it would be a non-starter. You also have the problem of making the range check for any value when one or the other bound could be invalid. More overhead in a particularly bad spot. So I don't think this idea is going to fly. Randy.