I question whether or not this is a "rejects valid": byLine explicitly states buffer re-use, so requesting a `ByLine!(immutable Char)` simply is not possible.
That said, I *would* see this as an enhancement, to have a line reader that always returns brand new buffers (in which case the line may or may not be immutable).
EG: By ByDupLine ?
Either that, or we simply keep using
`byLine().map!"a.dup"`
and
`byLine().map!"a.idup"`
That said, a `byDupLine` *is* a bit more user friendly, and helps limit levels of complexity in user code, as well as limits dependency on algorithm.
Comment #3 by monarchdodra — 2013-07-17T08:22:26Z
(In reply to comment #2)
> I question whether or not this is a "rejects valid": byLine explicitly states
> buffer re-use, so requesting a `ByLine!(immutable Char)` simply is not
> possible.
>
> That said, I *would* see this as an enhancement, to have a line reader that
> always returns brand new buffers (in which case the line may or may not be
> immutable).
>
> EG: By ByDupLine ?
>
> Either that, or we simply keep using
> `byLine().map!"a.dup"`
> and
> `byLine().map!"a.idup"`
>
> That said, a `byDupLine` *is* a bit more user friendly, and helps limit levels
> of complexity in user code, as well as limits dependency on algorithm.
In defense of the "ByDupLine" argument, one *BIG* advantage it can provide is that it can guarantee a single dup per front. `byLine().map!"a.dup`, on the other hand will call dup on every call to front.
Comment #4 by nick — 2013-07-17T09:48:23Z
(In reply to comment #2)
> I question whether or not this is a "rejects valid": byLine explicitly states
> buffer re-use, so requesting a `ByLine!(immutable Char)` simply is not
> possible.
Where does byLine state that?
Comment #5 by monarchdodra — 2013-07-17T15:04:45Z
(In reply to comment #4)
> (In reply to comment #2)
> > I question whether or not this is a "rejects valid": byLine explicitly states
> > buffer re-use, so requesting a `ByLine!(immutable Char)` simply is not
> > possible.
>
> Where does byLine state that?
Hum... I guess it doesn't actually state it (my bad). But even if un-documented, it is the "de facto" behavior, and the subject of countless threads on the boards.
If (*if*) we accept that ByLine is designed as a range wrapper to "readln(_front)", then we should take into account that readln *does* document buffer re-use...
That's my take on it anyways. I think adding support for this adds little value (IMO), and can only be exploited with a hard to use syntax.
Comment #6 by nick — 2013-07-18T08:08:27Z
(In reply to comment #2)
> I question whether or not this is a "rejects valid"
I suppose it's arguable, so I've now removed the rejects-valid keyword. (I think it did work before the readln(buf) change though).
> That said, I *would* see this as an enhancement, to have a line reader that
> always returns brand new buffers (in which case the line may or may not be
> immutable).
I have some ideas about other solutions, I will post something to the NG next week. I can't see how fixing this bug would be undesirable, but I agree byLine!(char, immutable char) is awkward syntax (I have an idea how to improve it).