comp.lang.ada
 help / color / mirror / Atom feed
From: mheaney@on2.com (Matthew Heaney)
Subject: Re: Adding "()" operator to Ada 200X
Date: 2 Jun 2003 16:42:33 -0700
Date: 2003-06-02T23:42:34+00:00	[thread overview]
Message-ID: <1ec946d1.0306021542.58714996@posting.google.com> (raw)
In-Reply-To: V0LCa.32473$ca5.11277@nwrdny02.gnilink.net

"Frank J. Lhota" <NOSPAM.lhota.adarose@verizon.net> wrote in message news:<V0LCa.32473$ca5.11277@nwrdny02.gnilink.net>...
> There appears to be wide agreement that Ada 200X should include some sort of
> standard container library like Charles and PragMark. This library will
> probably include generic packages for creating and operating with dynamic
> lists and maps. One can view these kinds of collections as generalized
> arrays, and as such, it would be nice to use array notation for accessing a
> member of one of these collections. 
>
[snip]
> I cannot help but think that this would be of tremendous help with whatever
> standard container library is added to Ada 200X.

But all you've done is change the syntax.  None of your suggestions
allow you to do more than is already provided by the library.

To get a constant view of an element object, then all you have to do
is:

procedure Op (I : Iterator_Type) is
   E : ET := Element (I);
begin

To get an element object reference, you have to use an intermediate
access type.  To query do this:

procedure Op (I : Iterator_Type) is
   X : ET := To_Access (I).all;
begin

To modify do this:

procedure Op (I : Iterator_Type) is
begin
   To_Access (I).all := Y;

If you prefer, you can rename the element object.

procedure Op (I : Iterator_Type) is
   E : ET renames To_Access (I).all;
begin
   X := E;  --query
   E := Y;  --modify
end;

Alternatively, if you don't want to mess around with access types,
then you can use Replace_Element instead:

  Replace_Element (I, E);

If this is a set or a map, you can always unconditionally modify an
element using Insert:

  Insert (Set, E);
  --sort of like Set (Get_Key (E)) := E;

  Insert (Map, Key, E);
  --sort of like Map (Key) := E;

If you're going to make a change in the syntax of the language, then
it has be because it allows you to do something you can't do already. 
For example, there's no way to declare an access subtype right now
that means "all the access values except null."  A useful language
change would be to allow the declaration:

  type Element_Access_Base is access all Element_Type;

  subtype Element_Access is Element_Access_Base range not null;



  reply	other threads:[~2003-06-02 23:42 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-06-02 16:35 Adding "()" operator to Ada 200X Frank J. Lhota
2003-06-02 23:42 ` Matthew Heaney [this message]
2003-06-03 14:59   ` Frank J. Lhota
2003-06-03 15:09     ` Frank J. Lhota
2003-06-03 16:04     ` Martin Krischik
2003-06-04 17:28       ` Matthew Heaney
2003-06-04 18:21         ` Frank J. Lhota
2003-06-05  1:15           ` Robert I. Eachus
2003-06-05 14:59             ` Frank J. Lhota
2003-06-05 17:25             ` Matthew Heaney
2003-06-03 20:24     ` Randy Brukardt
2003-06-03 19:52   ` Francisco Javier Loma Daza
2003-06-03  2:56 ` Fionn mac Cuimhaill
2003-06-03 14:02   ` Matthew Heaney
2003-06-03 16:23   ` Mário Amado Alves
2003-06-05 19:02     ` Dmitry A. Kazakov
2003-06-06 10:56       ` Mário Amado Alves
2003-06-06 16:55         ` Chad R. Meiners
2003-06-06 19:01         ` Frank J. Lhota
2003-06-09 14:15           ` Matthew Heaney
2003-06-07  8:36         ` Dmitry A. Kazakov
replies disabled

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