foreach ref very broken: fails to call front(val)
timon.gehr at gmx.ch
Tue Jul 10 15:15:34 PDT 2012
On 07/10/2012 11:51 PM, Jonathan M Davis wrote:
> On Tuesday, July 10, 2012 23:25:41 monarch_dodra wrote:
>> And more generally, how would code like this _ever_ work?
>> Array!int arr
>> foreach(ref a; arr)
>> a += 5;
>> Since there is no mechanism to pass the "op" to "front"?
> I believe that according to TDPL, if you use ref in a foreach with a range,
> and range.front = value isn't legal, then you should get a compilation error.
> Whether a += value works depends on whether range.front += value works, and at
> present, that's pretty much only going to work with ranges whose front returns
> by ref, since property syntax isn't currently sophisticated enough to combine
> the getter and setter properties to make stuff like front++ or front += 5
> - Jonathan M Davis
That is a bug. @property has very limited value if pairs of @property
functions are accessed in a way syntactically distinguishable from
More information about the Digitalmars-d