comp.lang.ada
 help / color / mirror / Atom feed
From: dewar@merv.cs.nyu.edu (Robert Dewar)
Subject: Re: Define Stream Input and Output for limited types ?
Date: 1996/11/30
Date: 1996-11-30T00:00:00+00:00	[thread overview]
Message-ID: <dewar.849365899@merv> (raw)
In-Reply-To: qw6zq02gmwv.fsf@esmeralda.enst.fr


">>>>> "Paul" == Paul Chardon <paul.chardon@avions.aerospatiale.fr> 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!






      reply	other threads:[~1996-11-30  0:00 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1996-11-28  0:00 Define Stream Input and Output for limited types ? Paul Chardon
1996-11-28  0:00 ` Samuel Tardieu
1996-11-30  0:00   ` Robert Dewar [this message]
replies disabled

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