comp.lang.ada
 help / color / mirror / Atom feed
From: "Randy Brukardt" <randy@rrsoftware.com>
Subject: Re: Little tutorial about streams
Date: Fri, 4 Mar 2011 19:35:39 -0600
Date: 2011-03-04T19:35:39-06:00	[thread overview]
Message-ID: <iks41e$jcf$1@munin.nbi.dk> (raw)
In-Reply-To: fba7e41d-288d-419a-ae55-86c2fd954903@glegroupsg2000goo.googlegroups.com

"mockturtle" <framefritti@gmail.com> wrote in message 
news:fba7e41d-288d-419a-ae55-86c2fd954903@glegroupsg2000goo.googlegroups.com...
> Dear all,
> I'm back.  First of all, thank you to everyone for your comments.  Let me 
> do a cumulative answer. I am afraid that this will make this post a bit 
> long.
...
>> ---- on Mar 1 2011 Randy Brukardt wrote
>>
>> It might make sense to mention that you can also specify these 
>> subprograms
>> with an aspect clause in Ada 2012
>
> I did not know about this.  Do you have a reference?

The draft standard and Rationale are the best references. But the rationale 
isn't close to done at this point (I've only seen a draft of Chapter 1 to 
date) and isn't public anyway. The current draft of the standard gives the 
syntax (see http://www.ada-auth.org/standards/ada12.html for the whole 
draft; specifically see 
http://www.ada-auth.org/standards/12rm/html/RM-13-3-1.html for the aspect 
syntax). The next draft will have essentially all of the details (probably 
available in April).

Anyway, the basic idea is that aspect clauses can be given as part of 
declarations. The "definition" is not resolved or evaluated until the entity 
declared by the declaration is frozen (formally until the end of the 
enclosing declaration list), so these are automatically "forward" 
references. For instance, you could have:

    type A_Type is ....
        with Read => My_Read,
               Write => My_Write;

   procedure My_Read (Stream : not null access 
Ada.Streams.Root_Stream_Type'Class;
                                     Item : out A_Type);

   procedure My_Write (Stream : not null access 
Ada.Streams.Root_Stream_Type'Class;
                                     Item : in A_Type);

This notation is most valuable for subprograms (since it sidesteps the 
problems of overloading that cause problems for pragmas and attribute 
definition clauses), but it is general and works on almost any declaration. 
(There are a few obscure things that are technically declarations -- like 
goto labels -- that don't allow aspect clauses.)

Just one of the good things coming in Ada 2012.

                                  Randy.





      parent reply	other threads:[~2011-03-05  1:35 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-02-28 17:00 Ann: Little tutorial about streams mockturtle
2011-02-28 20:32 ` Ludovic Brenta
2011-03-01  3:48 ` Randy Brukardt
2011-03-01  9:54   ` AdaMagica
2011-03-01 10:16   ` Dmitry A. Kazakov
2011-03-01 13:56     ` Simon Wright
2011-03-01 14:38       ` Dmitry A. Kazakov
2011-03-04 20:58         ` mockturtle
2011-03-05  1:08           ` Shark8
2011-03-05  1:35           ` Randy Brukardt [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