Bug 10662 – byLine!(Char, immutable Char) won't compile in git master

Status
RESOLVED
Resolution
WONTFIX
Severity
normal
Priority
P2
Component
phobos
Product
D
Version
D2
Platform
All
OS
All
Creation time
2013-07-17T04:59:00Z
Last change time
2014-04-10T15:14:53Z
Keywords
pull
Assigned to
nobody
Creator
nick

Comments

Comment #0 by nick — 2013-07-17T04:59:51Z
This won't compile because readln(buf) now requires a mutable buf. I have a fix ready to submit presently.
Comment #1 by nick — 2013-07-17T05:16:54Z
Comment #2 by monarchdodra — 2013-07-17T05:51:14Z
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).
Comment #7 by nick — 2014-04-10T15:14:53Z
Closed in favour of issue 12556.