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.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,e58de74cc10e4f9a X-Google-Attributes: gid103376,public From: dewar@merv.cs.nyu.edu (Robert Dewar) Subject: Re: Define Stream Input and Output for limited types ? Date: 1996/11/30 Message-ID: #1/1 X-Deja-AN: 201572506 references: <329DC065.1CFBAE39@avions.aerospatiale.fr> organization: New York University newsgroups: comp.lang.ada Date: 1996-11-30T00:00:00+00:00 List-Id: ">>>>> "Paul" == Paul Chardon writes: Paul> Because I wonder how I can define an attribute. Unfortunately, Paul> there is no example. " There doesn't need to be an example, remember the examples in the RM are not part of the standard, and you should not rely on them in any case. What you need to look for is the rule. In this case: 1. We know the syntax of an attribute definition clause, it is in 13.3(2): 2 attribute_definition_clause ::= for local_name'attribute_designator use expression; | for local_name'attribute_designator use name; The syntax rules are the easiest part of the RM to read! 2. Now we need to know if we can use an attribute definition clause for defining stream attributes. The important RM clause is 13.13.2(36) 36 The stream-oriented attributes may be specified for any type via an attribute_definition_clause. All nonlimited types have default implemen- tations for these operations. An attribute_reference for one of these attributes is illegal if the type is limited, unless the attribute has been specified by an attribute_definition_clause. For an attribute_definition_ clause specifying one of these attributes, the subtype of the Item parameter shall be the base subtype if scalar, and the first subtype otherwise. The same rule applies to the result of the Input function. Pretty clear. The only question is how to find such references. What I do is to keep an ASCII version of the RM online, then I can search it with very simple editor commands. It took only a few seconds to locate these two references, and by the way, I even came up with an example during my search, in 13.3(84): 84 function My_Read(Stream : access Ada.Streams.Root_Stream_Type'Class) return T; for T'Read use My_Read; -- see 13.13.2 The RM is not always easy to read, and in particular it is not always easy to find what you are looking for, particularly when you are looking for negative information (i.e. looking to make sure that nowhere in the RM does a certain rule appear), but in this case the search is pretty easy, and the paragraphs located easy enough to read!