From: Stephen Leake <Stephen.Leake@gsfc.nasa.gov>
Subject: Re: constant record components in Ada
Date: 1997/06/27
Date: 1997-06-27T00:00:00+00:00 [thread overview]
Message-ID: <33B43005.268C@gsfc.nasa.gov> (raw)
In-Reply-To: 5p100i$pvn@sutton.cs.columbia.edu
Alexander V. Konstantinou wrote:
>
> I am trying to obtain in Ada (95) the same functionality of the C++ struct
> declaration :
>
> struct map_pair {
> const Key_Type first;
> Value_Type second;
> }
>
> The idea is to provide a record in which the key value is constant, and the
> value type is mutable. The Ada books I have looked at suggest using
> discriminants. Unfortunately, discriminants have to be either discrete or
> access types. In my case Key_Type is a generic parameter and restricting it
> to be a discrete type is too restrictive.
Why is a discrete type too restrictive? Discrete types include integer
types and enumeration types; what other types are appropriate for keys?
Maybe fixed length strings?
>On the other hand, making the
> discriminant a pointer is in my view an ugly solution since it keeps that
> extra pointer around.
>
> Any ideas on how to tackle this ?
You could define a limited type to hold the key; then users could not
change it.
>
> Alexander V. Konstantinou
> --
> Alexander V. Konstantinou http://www.cs.columbia.edu/~akonstan/
> akonstan@cs.columbia.edu akonstan@acm.org
--
- Stephe
next prev parent reply other threads:[~1997-06-27 0:00 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
1997-06-27 0:00 constant record components in Ada Alexander V. Konstantinou
1997-06-27 0:00 ` Stephen Leake [this message]
1997-06-27 0:00 ` Robert Dewar
1997-06-29 0:00 ` Alexander V. Konstantinou
1997-06-27 0:00 ` Samuel Tardieu
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox