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: a07f3367d7,a568c3c1e0be03bf X-Google-Attributes: gida07f3367d7,public,usenet X-Google-NewGroupId: yes X-Google-Language: ENGLISH,ASCII-7-bit Received: by 10.204.141.4 with SMTP id k4mr479575bku.6.1339703850029; Thu, 14 Jun 2012 12:57:30 -0700 (PDT) Path: e27ni48490bkw.0!nntp.google.com!news1.google.com!news4.google.com!feeder3.cambriumusenet.nl!feed.tweaknews.nl!195.62.100.242.MISMATCH!newsfeed.kamp.net!newsfeed.kamp.net!eternal-september.org!feeder.eternal-september.org!mx04.eternal-september.org!.POSTED!not-for-mail From: Simon Wright Newsgroups: comp.lang.ada Subject: Re: Streams and abnormality Date: Tue, 12 Jun 2012 20:49:23 +0100 Organization: A noiseless patient Spider Message-ID: References: <9cd8589d-e8c1-402e-822e-d57aac39948e@googlegroups.com> Mime-Version: 1.0 Injection-Info: mx04.eternal-september.org; posting-host="VkRmmmXzMj956AdxXtqrqg"; logging-data="12942"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX199YJTHNIEtfv5tn0acOf29uDuLB0wEDS8=" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.4 (darwin) Cancel-Lock: sha1:AHIq2XGAD0Nx6yjB0ZNrxC7J6lE= sha1:MLZtvIpMCIOXI2apsCYXNH+35Fs= Content-Type: text/plain; charset=us-ascii Date: 2012-06-12T20:49:23+01:00 List-Id: Adam Beneschan writes: > On Tuesday, June 12, 2012 10:32:00 AM UTC-7, Simon Wright wrote: > > >> Looking at the AI[2], I must say I don't see quite where the >> "discriminants or if the component_declaration has a default_expression" >> comes from. > > Well, the wording was there in the first version of Ada 95 (AI95-195 > didn't change it). !summary 7 has to do with discriminants that don't > match when 'Read is called, the discriminants have default expressions > (otherwise they're not read from the stream), and the actual parameter > is constrained. It doesn't address the issue of invalid > representations. > > In RM12, the wording will be changed to "for each scalar component > that is a discriminant or that has an implicit initial value". But I > think this indicates that the wording was deliberate. I don't know > why it was important to specify this for components with default > expressions (or implicit initial values), and the Ada 95 Rationale > doesn't say. Anyway, your thinking that maybe they meant that it > applies only to discriminants with default expressions, doesn't make > sense; it has to apply to all discriminants, because the discriminant > could be used to control a variant part, and reading a discriminant > with an invalid value is going to wreak havoc regardless of whether it > has a default expression. > > -- Adam > >> It looks to me as though this should have read "discriminants whose >> component_declaration has a default_expression" (see !summary 7). Yes, I see. But nevertheless it seems that maybe the result of 'Input (or 'Read) needn't be checked in the case of a bare scalar. Would it be actually wrong for a compiler to check (in its default mode)? Looks like it ("For other components, no check is made."). Anyway, I'm writing an Ada implementation of Message_Pack[1]; since I'm not re-implementing 'Read or 'Input, I have to check values read from the stream. A Message_Pack stream contains items, where an item consists of an item-type byte followed, possibly, by more data; for example, 8388608 (2**23) would be {0xd2, 0x0, 0x80, 0x0, 0x0} ("int32" type byte, 4 bytes of big-endian data). Considering the (generic) code to read an integer type (range <>), I was thinking that if the item-type byte doesn't correspond to an integer value - for example, it might be 0xc2, false - I would raise Data_Error, whereas if the integral value read wouldn't match the required constraints I'd raise Constraint_Error. Does that seem reasonable? [1] http://msgpack.org