comp.lang.ada
 help / color / mirror / Atom feed
From: Martin <martin@thedowies.com>
Subject: Ada202X: Easy to use "UML private"-like components
Date: Fri, 21 Jun 2013 01:43:05 -0700 (PDT)
Date: 2013-06-21T01:43:05-07:00	[thread overview]
Message-ID: <69246de0-4b33-4d47-b5be-a45e8c911fb0@googlegroups.com> (raw)

I occasionally have the need to explain to people that Ada can support UML public, protected, private class data member scoping but to say it's confusing and clunky would be putting it mildly...

Firstly, I have to public - that's easy:

package CLA is
   type UML_Public is tagged record
      I : Integer; -- public to all, UML "public"
      F : Float;
   end record;
end CLA;


Secondly, I have to explain that using Ada "private" gives you "UML protected":

package CLA is
   type UML_Protected is tagged private;
private
   type UML_Protected is tagged record
      I : Integer; -- private to everyone excepted derived, UML "protected"
      F : Float;
   end record;
end CLA;

Finally, I have to explain that to get "UML private", you need to use an "opaque type" and and "access type":

package CLA is
   type UML_Private is tagged private;
private
   type Opaque;
   type UML_Private is tagged record
      I : Integer; -- private to everyone excepted derived, UML "protected"
      O : access Opaque;  -- has to be access, as compiler doesn't
                          -- know what Opaque is!
   end record;
end CLA;

package body CLA is
   type Opaque is record
      I : Integer; -- private to everyone, UML "private"
      F : Float;
   end record;
end CLA;




By now, the other person is usually rolling their eyes in disbelief and I'm nearly joining them...



There's nothing we can do about Ada "private" v UML "protected" but I think there is a relatively small addition that could be made to the language that would at least avoid the embarrassment of the third part.



My proposal would be to allow an optional "private component list" to record definitions, e.g.

package CLA is
   type UML_Private is tagged private;
private
   type UML_Private is tagged record
      I : Integer; -- private to everyone excepted derived, UML "protected"
   private
      F : Float; -- private to everyone - even derived, UML "private"
   end record;
end CLA;


Where a record had nothing but private components, it could either use:

Option 1:
   type T is tagged record
   private
      F : Float;
   end record;

or

Option 2:
   type T is tagged record
      null;
   private
      F : Float;
   end record;


I prefer Option 2.

Thoughts?

-- Martin

             reply	other threads:[~2013-06-21  8:43 UTC|newest]

Thread overview: 54+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-06-21  8:43 Martin [this message]
2013-06-21  9:23 ` Ada202X: Easy to use "UML private"-like components Dmitry A. Kazakov
2013-06-21  9:33   ` Martin
2013-06-21 10:14     ` G.B.
2013-06-21 11:19       ` Martin
2013-06-21 14:51     ` Dmitry A. Kazakov
2013-06-22 11:16       ` Martin
2013-06-22 12:10         ` Dmitry A. Kazakov
2013-06-21 18:36 ` Robert A Duff
2013-06-22 16:41   ` Niklas Holsti
2013-06-22 19:05     ` Dennis Lee Bieber
2013-06-22 22:57       ` Niklas Holsti
2013-06-23  3:26         ` Dennis Lee Bieber
2013-06-23  7:32           ` Niklas Holsti
2013-06-23 13:12             ` Robert A Duff
2013-06-23 14:06               ` Dmitry A. Kazakov
2013-06-23 15:15                 ` Robert A Duff
2013-06-23 18:52                   ` Dmitry A. Kazakov
2013-06-23 23:38                     ` Robert A Duff
2013-06-24  7:16                       ` Dmitry A. Kazakov
2013-06-24 20:11                         ` Randy Brukardt
2013-06-25  7:21                           ` Dmitry A. Kazakov
2013-06-25 19:06                             ` Randy Brukardt
2013-06-24 20:07                 ` Randy Brukardt
2013-06-23 14:40               ` Shark8
2013-06-23 15:28                 ` Robert A Duff
2013-06-23 18:14                   ` Bill Findlay
2013-06-23 23:43                     ` Robert A Duff
2013-06-23 23:48                       ` Bill Findlay
2013-06-24 20:16                   ` Randy Brukardt
2013-06-24 20:05               ` Randy Brukardt
2013-06-25  1:09                 ` Robert A Duff
2013-06-25 19:37                   ` Randy Brukardt
2013-06-23 12:28         ` Robert A Duff
2013-06-24 20:20           ` Randy Brukardt
2013-06-24 21:40             ` Niklas Holsti
2013-06-25  0:43               ` Robert A Duff
2013-06-25 19:23                 ` Randy Brukardt
2013-06-25 19:19               ` Randy Brukardt
2013-07-09 11:24   ` Martin
2013-07-09 14:39     ` Simon Wright
2013-07-10  7:03       ` Martin
2013-07-09 21:43     ` Robert A Duff
2013-07-10  6:34       ` Martin
2013-07-10  8:24         ` Dmitry A. Kazakov
2013-07-10 13:06           ` Martin
2013-07-10 16:12     ` Simon Wright
2013-07-10 18:22       ` Martin
2013-07-10 19:41         ` Simon Wright
2013-07-11 18:28           ` Martin
2013-07-11 19:37             ` Simon Wright
2013-07-11 20:43               ` Martin
2013-07-12  6:57                 ` Simon Wright
2013-07-12  8:05                   ` Martin
replies disabled

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