From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-0.9 required=5.0 tests=BAYES_00,FORGED_GMAIL_RCVD, FREEMAIL_FROM autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: 103376,36a29c2860aff686,start X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!postnews.google.com!s4g2000yql.googlegroups.com!not-for-mail From: Shark8 Newsgroups: comp.lang.ada Subject: Properties Date: Sat, 27 Nov 2010 19:21:55 -0800 (PST) Organization: http://groups.google.com Message-ID: <3b84c8e7-1a51-4a7c-9646-119f1fc51478@s4g2000yql.googlegroups.com> NNTP-Posting-Host: 174.28.198.93 Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 X-Trace: posting.google.com 1290914515 24235 127.0.0.1 (28 Nov 2010 03:21:55 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Sun, 28 Nov 2010 03:21:55 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: s4g2000yql.googlegroups.com; posting-host=174.28.198.93; posting-account=lJ3JNwoAAAAQfH3VV9vttJLkThaxtTfC User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/5.0 (Windows; U; Windows NT 6.0; en-US; rv:1.9.2.12) Gecko/20101026 Firefox/3.6.12 ( .NET CLR 3.5.30729; .NET4.0E),gzip(gfe) Xref: g2news1.google.com comp.lang.ada:15684 Date: 2010-11-27T19:21:55-08:00 List-Id: 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;