DIP23 draft: Fixing properties redux

Steven Schveighoffer schveiguy at yahoo.com
Sun Feb 3 10:33:40 PST 2013


On Sun, 03 Feb 2013 12:58:21 -0500, Timon Gehr <timon.gehr at gmx.ch> wrote:

> On 02/03/2013 06:47 PM, Steven Schveighoffer wrote:
>> On Sun, 03 Feb 2013 12:36:10 -0500, Andrei Alexandrescu
>> <SeeWebsiteForEmail at erdani.org> wrote:
>>
>>> On 2/3/13 7:40 AM, kenji hara wrote:
>>>> 2013/2/3 Steven Schveighoffer <schveiguy at yahoo.com
>>>> <mailto:schveiguy at yahoo.com>>
>>>>
>>>>     I have a possible suggestion to fix this within your proposal:
>>>>
>>>>     @property on single-arg free functions ONLY enables a setter mode,
>>>>     it does not work as a UFCS getter.
>>>>
>>>>   [snip]
>>>>
>>>> I was thinking the exact same thing.
>>>
>>> Then we can't make this work:
>>>
>>> @property ref T front(T[] array) { return array[0]; }
>>>
>>> unittest
>>> {
>>>     auto a = [ 1, 2, 3];
>>>     auto b = a.front;
>>> }
>>
>> ref T front(T[] array) { return array[0]; }
>>
>> // same unittest
>>
>
> different unittest:
>
> unittest{
>      auto a = [()=>2, ()=>3, ()=>4];
>      assert(a.front()==2);
> }

OK, so that is not good.  I think the current DIP23 idea should be  
sufficient, no global properties.

-Steve


More information about the Digitalmars-d mailing list