Proposal request: explicit propreties
Koroskin Denis
2korden+dmd at gmail.com
Tue Apr 1 07:13:12 PDT 2008
In my opinion, it is over-complicated.
On Tue, 01 Apr 2008 18:05:41 +0400, Jacob Carlborg <doobnet at gmail.com>
wrote:
> Ary Borenszweig wrote:
> I like the way it is now because you don't have to write the () after a
> function call (taking no arguments) if you like but I understand why
> explicit properties would be a good thing. If explicit properties were
> introduced in the language I would like this syntax:
>
> get T name (){}
> set T name (){}
>
> and also something I like to call property shortcut:
>
> 1) get string name;
> 2) set string name;
> 3) get set string name;
> 4) private set string name;
> 5) private set string name; public get string name;
> 6) static get string name;
> 7) get set
> {
> string name;
> int age;
> private string foo;
> }
>
> that would work something like read and write attributes in Ruby.
> 1) creates a private variable and a public get method
> 2) creates a private variable and a public set method
> 3) creates a private variable and a public get and set method
> 4) creates a private variable and a private set method
> 5) creates a private variable, a private set method and a public get
> method
> 6) creates a private static variable and a public static get method
> 7) creates three private variables, two public set methods (name and
> age), two public get methods (name and age), a private set method (foo)
> and a private get method (foo)
>
> The thing is that the variables always should be private, the methods
> would be public as default and if you put a protection attribute
> (public, private, protected ...) in front of a property shortcut it
> should affect only the created method.
>
More information about the Digitalmars-d
mailing list