comp.lang.ada
 help / color / mirror / Atom feed
From: Serge Robyns <serge.robyns@gmail.com>
Subject: Re: Declaring constants for a abstract tagged type and concrete sub classes
Date: Mon, 6 Jul 2015 14:16:29 -0700 (PDT)
Date: 2015-07-06T14:16:29-07:00	[thread overview]
Message-ID: <951038e0-77d0-43b2-aead-ad18cb09ecf5@googlegroups.com> (raw)
In-Reply-To: <87lhetb4oh.fsf@theworld.com>

On Monday, 6 July 2015 19:02:13 UTC+2, Bob Duff  wrote:
> Serge Robyns <> writes:
> 
> > type T_Root ...
> > No_Root_Element : T_Root := (a, b, c);
> >
> > type T_Sub is new T_Root ....
> > No_Sub_Element : T_Sub := ( ??? No_Root_Element ???, x, y z);
> 
> One possibility is to declare T_Root with default values for the
> components, such that those defaults are what you want for a "No_...".
> Then you can do:
> 
>     No_Sub_Element : T_Sub := (T_Root with X => X, Y => Y, Z => Z);
> 
> Or if T_Sub also has meaningful defaults, then:
> 
>     No_Sub_Element : T_Sub := (T_Root with others => <>);
> 
> I don't much like using default values, but in this kind of case
> it might be the best choice.
> 
> - Bob

I agree with you I don't like using default values as they will always initialize variables, even if they will be assigned some other values later.  For the moment (in my prototype) they are useful as not all data is yet useful populated.

One thing I'm still very much puzzled is the use of "<>" at many places.  I'm fine with it in generics, but failed to understand in class declaration or your assignment examples.  Looks like I failed to understand some chapters.  I did google to understand their use in abstract tagged types (found an example of a Virtual Proxy example in Ada using that kind of construct).


Serge

  reply	other threads:[~2015-07-06 21:16 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-07-06 10:10 Declaring constants for a abstract tagged type and concrete sub classes Serge Robyns
2015-07-06 11:55 ` G.B.
2015-07-06 13:49   ` Serge Robyns
2015-07-06 17:36     ` G.B.
2015-07-07 16:27       ` Serge Robyns
2015-07-07 17:21         ` G.B.
2015-07-07 19:51           ` Serge Robyns
2015-07-07 20:14             ` Simon Wright
2015-07-07 20:18             ` Jeffrey R. Carter
2015-07-06 15:42 ` Simon Wright
2015-07-06 16:35   ` Serge Robyns
2015-07-06 17:02     ` Bob Duff
2015-07-06 21:16       ` Serge Robyns [this message]
2015-07-06 17:30 ` gautier_niouzes
replies disabled

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