comp.lang.ada
 help / color / mirror / Atom feed
From: "Alexander E. Kopilovich" <aek@VB1162.spb.edu>
To: comp.lang.ada@ada-france.org
Subject: Re: Ada 2005?
Date: Tue, 21 Dec 2004 04:26:34 +0300 (MSK)
Date: 2004-12-21T04:26:34+03:00	[thread overview]
Message-ID: <mailman.205.1103592361.10401.comp.lang.ada@ada-france.org> (raw)
In-Reply-To: <m3acs8y1pt.fsf@rigel.goldenthreadtech.com>; from jayessay at 20 Dec 2004 18:44:14 -0500

jayessay wrote:

> "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de> writes:
[...]
> > The point is that:
> > 
> > 1. Prefix notation is misleading
>
> Not to mention inflexible and limiting.

And how about the following alternative (which was posted to Ada-Comment in
June 2003) ?

---------------------------------------------------------------------------

!summary

An alternative syntax is proposed here for AI-252. This alternative uses
new attribute instead of extension for meaning of dot-qualification, which is 
currently proposed in AI-252. This text assumes the context of current AI-252.

!proposal

Let us introduce new attribute Method, which always must be followed by dot
and operation, i.e.

  Object'Method.Operation

for example:

  type T is ... ;
  function F(A1 : T; A2 : Integer) return Integer;
  procedure P(A1: T);
  ...

  X : T;
  Actual_A2 : Integer;
  F_Result : Integer;
  ...

  F_Result := X'Method.F(Actual_A2);
  ...
  X'Method.P;

Conceptually, the attribute Method returns a record -- the table of all
relevant methods; some analogy with C++ code is present here, although the
major difference is obvious: contents of this table depends not only on the
object's type, but on surround and visibility rules also.

Basic visibility rules for Operation may stay as they are stated currently
in AI-252, but with additional option: a programmer can explicitly list all
visible packages for a particular subtype using appropriate "for...use"
statement:

  for Subtype'Method use Package1 [, Package2, ..., PackageN];

Such explicit statement overrides basic visibility rules for all
Object'Method.Operation expressions where Object belongs to Subtype.

Further, with this approach we may easily provide a denotation for the
component-on-demand abstraction, that is, unified notation for an externally
immutable view of a data component and a function; all we need for this is
another attribute Property, which should be used the same way:

  Object'Property.Function_Or_DataField

for example, for both

  type T is ... ;
  function F(P : T) return Integer;

and

  type T is record
     F : Integer;
     ...
  end record;

we can write:

  X : T;
  R : Integer;
  ...

  R := X'Property.F;

Arguments for a function prefixed by the Property attribute naturally
correspond indices for array data component.

Further, arrays (that are indexed by controlling object type) likewise may be
used in conjunction with the Property attribute  (in accordance with analogy
between arrays and functions, supported in Ada). For example:

  type String_Index is new Integer;
  S : String(1..10);
  I : String_Index;
  ...
  ... I'Property.S ...

Even multi-dimensional arrays are permitted here. For example:

  type Cities is (Edinburgh, Glasgow, London, Paris, New_York);
  type Distances is array (Cities, Cities) of Float;
  Km_To : Distances := ...;
  ...
  ... Edinburgh'Property.Km_To(Paris) ...

As for arrays of arrays, only outer array may be used, that is, the subscripts
for inner arrays cannot appear. For example:

  type Table_Index is new Integer;
  type Table_Line is String(1..50);  
  Table : array (Table_Index range 1..10) of Table_Line;
  I : Table_Index;
  ...
  ... I'Property.Table ...     -- legal
  ...
  ... I'Property.Table(1) ...  -- illegal


!discussion

Object.Operation syntax seems as acceptable compromise in a case when
there is a controlling object. Although even then the Operation does not
belong to the Object (as it belongs to a package), it is reasonable to claim
that conceptually, the status of being controlling temporary gives the Object
some additional rights over all its operations, and in particular, extends
visibility rules for the Object.

But in many cases there are no controlling objects, and in those cases this
Object.Operation syntax will act against proper expression and understanding
of program design and logic. Moverover, as this Object.Operation style
potentially conflicts with package-orientation, which is fundamental feature
of Ada 95, and as this Object.Operation notation is compulsory in most of
today's mainstream languages, there is real possibility of massive and
disordered mixture of those design styles if this Object.Operation notation
appear in Ada.

There is also anxiety about possible confusion with component notation.
As Robert I. Eachus recently wrote in comp.lang.ada newsgroup
(message-id <3ED056CB.8000200@attbi.com> ):
"I really don't like the idea of allowing the Object.Operation format to 
Ada.  Yeah, the compilers can usually figure it out understand it. But 
the potential confusion with component notation is going to confuse 
experienced Ada users.  (And eventually other O-O language users when 
the actually run into component references."

An alternative proposed here attains main purpose of AI-252, and it does not
contest AI's propositions concerning all things except Object.Operation
syntax. At the same time it establishes a deterrent for unjustified use of
the feature (by extra wording), makes the expression of programmer's intent
more explicit, and additionally, provides finer control over visibility and
over interchangeability between operation and data field.

The level of uniformity achieved with the notation proposed here is even
higher than with dot-notation proposed in current AI-252 (because the arrays
are included) without sacrificing traditional features and natural ways for
expressing specific intentions.

---------------------------------------------------------------------------




  reply	other threads:[~2004-12-21  1:26 UTC|newest]

Thread overview: 55+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-12-18  4:27 Ada 2005? conradwt
2004-12-18  8:08 ` Martin Dowie
2004-12-20 20:06   ` conradwt
2004-12-21  6:51     ` Martin Dowie
2004-12-18  8:47 ` christov
2004-12-19  3:28   ` Randy Brukardt
2004-12-19 19:11     ` christov
2004-12-19 22:07       ` Ada User Journal (was: Re: Ada 2005?) Dirk Craeynest
2004-12-19 22:34         ` Ada User Journal Florian Weimer
2004-12-20  9:19           ` Martin Krischik
2004-12-20 11:02             ` Florian Weimer
2004-12-20 12:22               ` Thomas Hühn
2004-12-27 13:16                 ` Florian Weimer
2004-12-21  0:15   ` Ada 2005? David Botton
2004-12-18  8:51 ` Martin Krischik
2004-12-18 16:03 ` Dmitry A. Kazakov
2004-12-20 18:49   ` conradwt
2004-12-20 20:10     ` Dmitry A. Kazakov
2004-12-20 23:44       ` jayessay
2004-12-21  1:26         ` Alexander E. Kopilovich [this message]
2004-12-21  8:31           ` Dmitry A. Kazakov
2004-12-21 17:24           ` jayessay
2004-12-21  8:11         ` Dmitry A. Kazakov
2004-12-21 17:10           ` jayessay
2004-12-21 17:12             ` Dmitry A. Kazakov
2004-12-21 21:42               ` jayessay
2004-12-22  8:55                 ` Dmitry A. Kazakov
2004-12-22 18:02                   ` jayessay
2004-12-22 19:10                     ` Dmitry A. Kazakov
2004-12-23 18:09                       ` jayessay
2004-12-24  9:41                         ` Dmitry A. Kazakov
2004-12-27 17:09                           ` jayessay
2004-12-27 19:44                             ` Dmitry A. Kazakov
2004-12-27 21:51                               ` Georg Bauhaus
2004-12-28  9:56                                 ` Dmitry A. Kazakov
2004-12-28 17:56                                   ` jayessay
2004-12-28 17:48                                 ` jayessay
2004-12-28 17:36                               ` jayessay
2004-12-21  8:33     ` Martin Krischik
2004-12-21 15:34       ` jimmaureenrogers
2004-12-21 15:53         ` Martin Krischik
2004-12-22  9:34           ` Larry Kilgallen
2004-12-22 11:01             ` Martin Krischik
2004-12-22 12:52               ` Larry Kilgallen
2004-12-22 16:38                 ` Martin Krischik
2004-12-23 23:05       ` conradwt
2004-12-24  9:24         ` Pascal Obry
2004-12-24  9:59         ` Martin Krischik
2004-12-18 19:31 ` Jeffrey Carter
2004-12-20 18:55   ` conradwt
2004-12-20 23:53     ` Jeffrey Carter
2004-12-21  0:25       ` David Botton
2004-12-19  3:16 ` Brian May
2004-12-20 23:38   ` jayessay
2004-12-21 21:42     ` Brian May
replies disabled

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