Ranges, constantly frustrating
Regan Heath
regan at netmail.co.nz
Wed Feb 12 02:47:38 PST 2014
On Tue, 11 Feb 2014 19:16:31 -0000, Steven Schveighoffer
<schveiguy at yahoo.com> wrote:
> On Tue, 11 Feb 2014 05:10:27 -0500, Regan Heath <regan at netmail.co.nz>
> wrote:
>
>> Things like this should "just work"..
>>
>> File input ...
>>
>> auto range = input.byLine();
>> while(!range.empty)
>> {
>> range.popFront();
>> foreach (i, line; range.take(4)) //Error: cannot infer argument
>> types
>> {
>> ..etc..
>> }
>> range.popFront();
>> }
>>
>> Tried adding 'int' and 'char[]' or 'auto' .. no dice.
>>
>> Can someone explain why this fails, and if this is a permanent or
>> temporary limitation of D/MD.
>
> This is only available using opApply style iteration. Using range
> iteration does not give you this ability.
>
> It's not a permanent limitation per se, but there is no plan at the
> moment to add multiple parameters to range iteration.
>
> One thing that IS a limitation though: we cannot overload on return
> values. So the obvious idea of overloading front to return tuples of
> various types, would not be feasible. opApply can do that because the
> delegate is a parameter.
Thanks for the concise/complete response. I had managed to piece this
together from other replies but it's clearer now.
R
--
Using Opera's revolutionary email client: http://www.opera.com/mail/
More information about the Digitalmars-d-learn
mailing list