@property - take it behind the woodshed and shoot it?

Adam Wilson flyboynw at gmail.com
Mon Jan 28 13:40:09 PST 2013


On Mon, 28 Jan 2013 05:26:43 -0800, Regan Heath <regan at netmail.co.nz>  
wrote:

> On Sat, 26 Jan 2013 16:29:16 -0000, Andrei Alexandrescu  
> <SeeWebsiteForEmail at erdani.org> wrote:
>
>> On 1/26/13 8:21 AM, Jacob Carlborg wrote:
>>> On 2013-01-25 22:20, Andrei Alexandrescu wrote:
>>>
>>>> That's right with the amendment that we're looking for a solution, not
>>>> pushing one. Even the title of the thread is a question.
>>>>
>>>> Clearly properties are good to have. In an ideal world we wouldn't  
>>>> need
>>>> a keyword for them and we'd have some simple rules for determining
>>>> property status (especially when it comes to writes). If syntactic  
>>>> help
>>>> is necessary, so be it. We want to make the language better, not  
>>>> worse.
>>>
>>> It's always possible to avoid keywords in favor of syntax. Example:
>>>
>>> Declaring a getter:
>>>
>>> int foo {}
>>>
>>> Just as a regular function declaration but without the parentheses.
>>>
>>> Declaring a setter:
>>>
>>> void foo= (int value) {}
>>>
>>> Append an equal sign to the function name.
>>
>> This is interesting. I wonder how to make it work for UFCS functions  
>> (which _do_ have one argument).
>
> Do the c# thing and use 'this'? i.e.
>
> int foo(this Person p) {}
> void foo= (this Person p, int value) {}
>
> R
>

Yes, C# uses a 'this' argument as it's first parameters to make it an  
Extension Method.

-- 
Adam Wilson
IRC: LightBender
Project Coordinator
The Horizon Project
http://www.thehorizonproject.org/


More information about the Digitalmars-d mailing list