comp.lang.ada
 help / color / mirror / Atom feed
From: Shark8 <onewingedshark@gmail.com>
Subject: Properties
Date: Sat, 27 Nov 2010 19:21:55 -0800 (PST)
Date: 2010-11-27T19:21:55-08:00	[thread overview]
Message-ID: <3b84c8e7-1a51-4a7c-9646-119f1fc51478@s4g2000yql.googlegroups.com> (raw)

I would like to submit a proposal for future Ada development; namely
"Properties." The purpose of this thread is to: 1) present the ideas
in general; 2) bounce ideas for the syntax off of fellow Ada users; 3)
work on presenting ideas to others; and  4) obtain the information to
submit the proposal.

1 -- Properties
Properties, as used here, are a typed member elements of either an
object or an interface displayed publicly which may be read-only,
write-only, or read-write and which may rename another member element
or a procedure/function.

In the case of interfaces they can greatly reduce the number of public
entities as all getters and setters may be hidden from the public view
and be 'collapsed' into reads and writes [respectively] to the
corresponding property.

2 -- Syntax Proposal
Part 1 -- Declaring a property
I propose reusing the SEPARATE keyword to mark properties.
Example:
Type Button is tagged record
  Text : Separate Access String;
end record;

Part 2 -- Specifying readability and writability
For declaring whether a property is read-only, write-only, or read-
write {The unreadable/unwritable state is useless and should be
excluded.} I propose using read-write as the default and specifying
read-only or write only via attributes "Readable" and/or "Writable".
Example:
For Property_Name'Writable Use False;
and
For Property_Name'Readable Use False;

If we default both Readable and Writable to true and allow only one to
be declared to be false then we achieve size-optimization in the code
for the common case of read-write and prohibit the unreadable/
unwritable properties.

Part 3 -- Specifying procedures or fields
I propose expanding/overloading the 'Read and 'Write attributes onto
the particular property of some type to specify its


Example:

Package Time is
SubType Hour is Natural Range 0..23;
SubType Minute is Natural 0..59;
Type Clock is tagged record
Internal_Time : record    ---  Some implementation/OS dependent time
                           Date : Integer;
                           M     : Minute; --- For some reason minutes
are stored separately on this os.
                       end record;
H : Separate Hour;
M : Separate Minute;
End record;

Private
 Function Get_Hour( Object : In Clock ) Return Hour;
 Function Get_Minute( Object : In Clock ) Return Minute;
 Procedure Set_Hour( Object : In Out Clock; Value : In Hour );
 Procedure Set_Minute( Object : In Out Clock; Value : In Minute );

For Clock.H'Read use Get_Hour;
For Clock.H'Write use Set_Hour;
For Clock.M'Read use Internal_Time.M;
For Clock.M'Write use Internal_Time.M;
End Time;


Part 4 -- Arrays
I propose that properties of an array-type should, when aliasing a
function or procedure, should require the forms of:
Function Get_Property_Value( Input : In Array_Type; Index_1 : in
Array_Index1_Type ) Return Array_Element_Type;
Procedure Set_Property_Value( Input : In Array_Type; Index_1 : in
Array_Index1_Type; Value In Array_Element_Type );

In the case of multidimensional arrays we would expand the parameter-
list accordingly, i.e. two dimensions, for getting, would yield a
function of the form:
Function Get_Property_Value( Input : In Array_Type; Index_1 : in
Array_Index1_Type; Index_2 : In Array_Index2_Type ) Return
Array_Element_Type;

Part 5 -- Public properties and private fields
Currently it is possible to hide the internals of a publicly used type
by forward-declaring the type in the public section of a specification
and completing the type in the private section.; in order to maintain
this ability, yet allow properties to be publicly accessed I propose
the use of the keywords SEPARATE & RECORD to allow the following:

Package GUIs is
Type Button is tagged separate record
  Top, Left, Height, Width : Separate Natural;  --- Only properties
are allowed to be declared here
end record;

Private
Type Button is Tagged record
 Caption : String;
 On_Click : Procedure( Item : In Out Button );
 -- ...
end record;

--...

End GUIs;



             reply	other threads:[~2010-11-28  3:21 UTC|newest]

Thread overview: 96+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-11-28  3:21 Shark8 [this message]
2010-11-28  8:15 ` Properties Dmitry A. Kazakov
2010-11-28 19:43   ` Properties Shark8
2010-11-29  8:34     ` Properties Dmitry A. Kazakov
2010-12-01 18:15       ` Properties Shark8
2010-11-28 12:37 ` Properties Georg Bauhaus
2010-11-28 21:22   ` Properties Shark8
2010-11-29 16:54     ` Properties Georg Bauhaus
2010-12-01 19:52   ` Properties Martin Krischik
2010-12-01 23:24     ` Properties Georg Bauhaus
2010-12-05 16:15       ` (placepo) Properties Martin Krischik
2010-12-06 23:24         ` Shark8
2010-12-01 23:31     ` Properties Georg Bauhaus
2010-11-30  1:49 ` Properties Randy Brukardt
2010-11-30 16:58   ` Properties Charmed Snark
2010-11-30 17:22     ` Properties Dmitry A. Kazakov
2010-11-30 20:27       ` Properties Warren
2010-12-01  8:39         ` Properties Dmitry A. Kazakov
2010-12-01 15:21           ` Properties Warren
2010-12-01 15:59             ` Properties Dmitry A. Kazakov
2010-12-01 16:20               ` Properties Warren
2010-12-01 18:22                 ` Properties Dmitry A. Kazakov
2010-12-01 19:36                   ` Properties Shark8
2010-12-01 21:13                     ` Properties Dmitry A. Kazakov
2010-12-01 21:35                   ` Properties Maciej Sobczak
2010-12-01 21:45                     ` Properties Dmitry A. Kazakov
2010-12-02  9:57                       ` Properties Maciej Sobczak
2010-12-02 10:26                         ` Properties Dmitry A. Kazakov
2010-12-02 15:25                           ` Properties Maciej Sobczak
2010-12-02 15:46                             ` Properties Dmitry A. Kazakov
2010-12-02 21:11                               ` Properties Maciej Sobczak
2010-12-02 22:19                                 ` Properties Dmitry A. Kazakov
2010-12-03  4:43                                 ` Properties Randy Brukardt
2010-12-03 13:53                                   ` Properties Maciej Sobczak
2010-12-03 21:32                                     ` Properties Randy Brukardt
2010-12-04 22:13                                       ` Properties Maciej Sobczak
2010-12-06 23:30                                         ` Properties Shark8
2010-12-06 23:33                                         ` Properties Randy Brukardt
2010-12-04 17:43                           ` Properties Simon Wright
2010-12-04 20:48                             ` Properties Dmitry A. Kazakov
2010-12-04 22:27                               ` Properties Simon Wright
2010-12-04 22:31                                 ` Properties Vinzent Hoefler
2010-12-03  4:24                         ` Properties Randy Brukardt
2010-12-03  5:00                         ` Properties Shark8
2010-12-03 21:10                           ` Properties Randy Brukardt
2010-12-03 23:34                           ` Properties Jeffrey Carter
2010-12-06  6:02                             ` Properties Brad Moore
2010-12-06 23:25                               ` Properties Shark8
2010-12-01 19:48                 ` Properties Randy Brukardt
2010-12-01 21:10                   ` Properties Warren
2010-12-02  0:03                     ` Properties Shark8
2010-12-02 16:45                       ` Properties Warren
2010-12-02 17:32                         ` Properties Dmitry A. Kazakov
2010-12-02 20:45                           ` Properties Warren
2010-12-02 21:17                             ` Properties Adam Beneschan
2010-12-02 21:40                               ` Properties Warren
2010-12-03  3:34                             ` Properties Shark8
2010-12-03  8:16                               ` Properties Thomas Løcke
2010-12-02 20:52                           ` Properties Pascal Obry
2010-12-02 19:46                         ` Properties Adam Beneschan
2010-12-02 20:38                           ` Properties Warren
2010-12-02 21:39                             ` Properties Jeffrey Carter
2010-12-02 21:55                               ` Properties Warren
2010-12-03  9:33                               ` Properties Anonymous
2010-12-03  3:47                           ` Properties Shark8
2010-12-03  0:09                         ` Properties Robert A Duff
2010-12-03 15:49                           ` Properties Warren
2010-12-03 20:07                             ` Properties Shark8
2010-12-06 21:01                               ` Properties Warren
2010-12-06 23:22                                 ` Properties Shark8
2010-12-07 14:37                                   ` Properties Warren
2010-12-08 21:13                                   ` Properties Simon Wright
2010-12-09  1:21                                     ` Properties Shark8
2010-12-06 23:43                                 ` Properties Randy Brukardt
2010-12-07  0:56                                   ` Properties Jeffrey Carter
2010-12-07 11:23                                   ` Properties Maciej Sobczak
2010-12-07 11:51                                     ` Properties Georg Bauhaus
2010-12-07 15:35                                       ` Properties Maciej Sobczak
2010-12-07 17:02                                         ` Properties Georg Bauhaus
2010-12-07 14:39                                   ` Properties Warren
2010-12-03 15:40                         ` Properties Warren
2010-12-03 19:56                           ` Properties Shark8
2010-12-03 20:12                             ` Properties Warren
2010-12-03  5:53               ` Properties Shark8
2010-12-03  9:05                 ` Properties Dmitry A. Kazakov
2010-12-03 19:52                   ` Properties Shark8
2010-12-03 21:14                     ` Properties Randy Brukardt
2010-12-04  5:35                       ` Properties Shark8
2010-12-04 14:23                         ` Properties Peter C. Chapin
2010-12-04 18:53                           ` Properties Shark8
2010-12-13 15:10                       ` Properties Brian Drummond
2010-12-03 22:38                     ` Properties Dmitry A. Kazakov
2010-12-04  3:12                       ` Properties Shark8
2010-12-04 13:19                     ` Properties Georg Bauhaus
  -- strict thread matches above, loose matches on Subject: below --
2010-12-04 19:53 Properties Shark8
2010-12-04 23:27 ` Properties Thomas Løcke
replies disabled

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