[phobos] Time to get ready for the next release

Robert Jacques sandford at jhu.edu
Thu Apr 21 16:16:15 PDT 2011


On Thu, 21 Apr 2011 18:57:18 -0400, Michel Fortin  
<michel.fortin at michelf.com> wrote:

> Le 2011-04-21 à 17:54, Robert Jacques a écrit :
>
>> First, remember that basic assignments can be chained: x = y = 1; So a  
>> property should never return void, whether it's a setter or a getter  
>> logically.
>
> Indeed. You'd expect the property to return the value you set to it.
>
>
>> Second, there are situations where you want to be able to support:
>>
>> a.prop1 =  5;
>>
>> and
>>
>> auto b = a.prop1(5).prop2(6);
>
> But here you have a dilemma. To work like "x = y = 1" above, "a.prop1 =  
> 5" should return "5". But to work with chaining, "a.prop1(5)" should  
> return "a". How do you make that work?

Assignment chaining and method chaining are not compatible, as far as I  
know. I was using "x = y = 1" as a counter-argument; i.e. as an  
illustration that fields/property assignment could/should have a return  
value. In the later example, something like `c = a.prop1 = 5` would only  
work if is(typeof(c) == typeof(a)). So, a.prop1 isn't 100% faithful to the  
field semantics which generally define what a strict 'property' should be.  
But on the other hand, the API design of 'a' desires that prop1 be  
accessible via both method and field style invocation, something that's  
possible today using Methods-as-Fields but not with @property alone.


More information about the phobos mailing list