From: David Sauvage <david.sauvage@adalabs.com>
Subject: Re: Why constant components are not permitted ?
Date: Mon, 28 Nov 2011 23:55:49 -0800 (PST)
Date: 2011-11-28T23:55:49-08:00 [thread overview]
Message-ID: <009a0d10-706d-4c9c-824e-68995676a1ea@cc2g2000vbb.googlegroups.com> (raw)
In-Reply-To: jb1lv3$9l7$1@munin.nbi.dk
On 29 nov, 08:10, "Randy Brukardt" <ra...@rrsoftware.com> wrote:
> "Niklas Holsti" <niklas.hol...@tidorum.invalid> wrote in message
>
> news:9ja2aiFla6U1@mid.individual.net...
> ...
>
> > The original poster specified the constant value in the declaration of the
> > record *type*, not separately for each record *object*. This is what I do
> > not understand: what is the use of a value that is the same for all
> > objects in which it can appear?
>
> One such use is in interfacing when some components always have fixed
> values. For instance, most record types in Win32 have a Size component that
> is always the same for a particular type declaration. It would be nice to
> declare that as a constant (since it cannot change).
>
> But this need is so rare and unusual it hardly makes sense to add language
> support for it. The story would be different for a new from-scratch language
> design; the omission looks like a mistake in Ada and it surely would be more
> consistent to have it even if it is rarely used. But redoing the Standard
> and existing implementations needs a better reason than "more consistent but
> rarely used".
>
> Randy.
Why use a constant attribute in a record ?
To expose my design intention in the code.
I will have a big tagged types hierarchy, and wanted to declare a read
only component in each root tagged types, so that when users will use
the framework and add child types, they will not been able to modify
this attribute.
I would not been able to do this using a primitive method as they
would be able to override it (think of the final keywork in Java to
prevent a method from being overridden).
Anyway, my question concern the rational of why this is not possible
in Ada, and I got some answers.
Thanks to all for your inputs.
Cheers,
next prev parent reply other threads:[~2011-11-29 8:21 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-11-24 18:14 Why constant components are not permitted ? David Sauvage
2011-11-24 19:06 ` anon
2011-11-24 19:49 ` David Sauvage
2011-11-24 22:55 ` Georg Bauhaus
2011-11-24 23:53 ` anon
2011-11-24 19:46 ` Ludovic Brenta
2011-11-25 9:10 ` Dmitry A. Kazakov
2011-11-25 10:23 ` Ludovic Brenta
2011-11-25 10:45 ` Dmitry A. Kazakov
2011-11-25 6:56 ` Niklas Holsti
2011-11-25 9:53 ` Yannick Duchêne (Hibou57)
2011-11-25 10:06 ` AdaMagica
2011-11-25 10:16 ` AdaMagica
2011-11-25 10:56 ` Yannick Duchêne (Hibou57)
2011-11-25 17:41 ` Niklas Holsti
2011-11-26 0:23 ` anon
2011-11-29 4:10 ` Randy Brukardt
2011-11-29 7:55 ` David Sauvage [this message]
2011-11-29 10:55 ` Yannick Duchêne (Hibou57)
2011-11-29 11:17 ` Mark Lorenzen
2011-11-26 10:22 ` Pascal Obry
2011-11-26 10:59 ` Dmitry A. Kazakov
2011-11-25 7:03 ` AdaMagica
2011-11-25 9:12 ` Dmitry A. Kazakov
2011-11-25 9:57 ` Yannick Duchêne (Hibou57)
2011-11-25 10:22 ` Dmitry A. Kazakov
2011-11-25 11:00 ` Yannick Duchêne (Hibou57)
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox