comp.lang.ada
 help / color / mirror / Atom feed
* Define Stream Input and Output for limited types ?
@ 1996-11-28  0:00 Paul Chardon
  1996-11-28  0:00 ` Samuel Tardieu
  0 siblings, 1 reply; 3+ messages in thread
From: Paul Chardon @ 1996-11-28  0:00 UTC (permalink / raw)



Hello,

	I,m reading a paragragh in the ARM95 and I'mnot sure to well understand
it. So, if anyone can tell me more about that.

ARM95 A.4.1 Stream Input and Output (sixth paragraph)

"Sequential processing of streams is performed using attributes T'Read,
T'Write, T'Input and T'Output. These attributes are predefined for
non-limited types. The user can replace them by providing an attribute
definition clause and can also define such attributes explicitily for
limited types. ..."

"define such attributes" : does it mean giving a value to such an
attribute for a limited type for it is got no default.

for Limited_Type'Read use My_Read_Procedure;

Because I wonder how I can define an attribute. Unfortunately, there is
no example.

	Thanks, Paul.

P.S.: Sorry, if you think it is a dummy question.




^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Define Stream Input and Output for limited types ?
  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
  0 siblings, 1 reply; 3+ messages in thread
From: Samuel Tardieu @ 1996-11-28  0:00 UTC (permalink / raw)
  To: Paul Chardon


>>>>> "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.

Let's make an example:

   type My_Type is limited null record;

   procedure My_Write (Where : access Ada.Streams.Root_Stream_Type'Class;
                       What  : in My_Type);

   for My_Type'Write use My_Write;

and so on for the Read attribute. Of course, in this case (limited
null record), My_Write would be very simple :-)

  Sam
-- 
  Samuel Tardieu -- sam@ada.eu.org




^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Define Stream Input and Output for limited types ?
  1996-11-28  0:00 ` Samuel Tardieu
@ 1996-11-30  0:00   ` Robert Dewar
  0 siblings, 0 replies; 3+ messages in thread
From: Robert Dewar @ 1996-11-30  0:00 UTC (permalink / raw)



">>>>> "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!






^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~1996-11-30  0:00 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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 is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox