comp.lang.ada
 help / color / mirror / Atom feed
From: "ME" <abcdefg@nonodock.net>
Subject: Re: Ada 2005 box (<>) rules in default values
Date: Tue, 17 Jan 2006 05:35:52 -0800
Date: 2006-01-17T05:35:52-08:00	[thread overview]
Message-ID: <11spsltn78ido25@corp.supernews.com> (raw)
In-Reply-To: 43CCAB76.6050907@mailinator.com

When will a Ada 2005 compiler become publicly available i.e. gnat 16.0P?
"Alex R. Mosteo" <devnull@mailinator.com> wrote in message 
news:43CCAB76.6050907@mailinator.com...
> Hi all,
>
> I have a doubt with the box operator as newly introduced in Ada 2005 to 
> allow in place initialization of limited types. I'm not sure of all the 
> details so anything I say can be wrong; if so please correct me.
>
> My understanding is that you use the <> value to denote the default value 
> of a field in, for example a (limited or not) record:
>
> Blah : constant Thing :=
>  (First_Component  => 3,
>          Second_Component => 4,
>          others => <>);
>
> This actually compiles in GNAT GAP/GPL, but there's a thing happening that 
> I don't know if it's that it isn't still completely implemented in Gnat, 
> or is the expected behavior.
>
> Say, for example, that Thing above is declared like:
>
> type Thing is record
>    First_Component  : Integer;
>    Second_Component : Integer;
>    Third_Component  : Integer := 5;
> end record;
>
> I'm finding that if I use the box as in the first example above, the third 
> component will not receive its default value from the type definition (5), 
> but will be uninitialized. I've noticed this because initializing types 
> like this:
>
> type Other_Thing is record
>     X : Integer;
>     L : List;
>     -- From some instantiation of Ada.Containers.Doubly_Linked_Lists
> end record;
>
> with
>
> Y : Other_Thing := (X => 5, others => <>);
>
> This initialization more often than not will have an invalid list (i.e. 
> not an empty list, but one with improper values that fails when used).
>
> I've read the Aggregates Issues in the "Gnat and Ada 2005" document, and 
> there the <> initializer is mentioned primarily in relation to limited 
> types. From that document I read:
>
> "The box notation ("<>") is now used to denote the default initialization 
> for a component of an aggregate, that is to say an invocation of the 
> initialization procedure for the component type."
>
> And
>
> "Note that the "others => <>" notation is allowed even when the associated 
> components are not of the same type. Its meaning is as follows: if a 
> component has a default expression in the record type, the expression is 
> used; otherwise, the normal default initialization for its type is used."
>
> From these paragraphs I understand that Gnat is not implementing correctly 
> that feature for the moment. So I ask if you knowledgeable lot agree with 
> my impression. (A pointer to the amendment dealing with this will also be 
> welcome). 





  parent reply	other threads:[~2006-01-17 13:35 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-01-17  8:31 Ada 2005 box (<>) rules in default values Alex R. Mosteo
2006-01-17  9:35 ` Martin Dowie
2006-01-17 13:35 ` ME [this message]
2006-01-17 17:19   ` Pascal Obry
2006-01-17 20:25     ` Randy Brukardt
2006-01-17 20:29 ` Randy Brukardt
2006-01-17 21:15 ` Björn Persson
2006-01-18 11:04   ` Alex R. Mosteo
2006-01-18 14:09     ` Jean-Pierre Rosen
2006-01-18 15:59       ` Alex R. Mosteo
2006-01-18 21:54         ` Randy Brukardt
2006-01-19  9:19           ` Alex R. Mosteo
2006-01-18 21:32     ` Björn Persson
replies disabled

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