property syntax strawman
Sergey Gromov
snake.scaly at gmail.com
Tue Aug 4 05:12:54 PDT 2009
Tue, 4 Aug 2009 01:15:45 +0400, Sergey Gromov wrote:
> Mon, 03 Aug 2009 11:06:53 -0400, Steven Schveighoffer wrote:
>
>> I just thought of another issue with property definitions. How do you
>> declare a property of an array? Today it's:
>>
>> char[] chomped(char[] input);
>>
>> Note that any getter property contains an argument which is the object
>> you're calling the property on (normally implied because the definition is
>> inside an aggregate definition). But with arrays it's explicit.
>>
>> So how does this fit in Walter's proposed syntax?
>>
>> char[] chomped {...}
>>
>> Where does the input go?
>
> I proposed a keyword, 'inject', a year ago. Or it could be an
> annotation. I suppose such a keyword might significantly simplify
> implmentation of external functions and properties:
>
> @inject @property char[] chomped(char[] arr) {...}
> @inject void sort!(alias pred, T)(T[] arr) {...}
>
> Though prepending 'this' to the first parameter may also work, C# style.
Or, this can work with Walter's syntax:
@extension!char[] char[] chomped {...}
More information about the Digitalmars-d
mailing list