Bug 21860 – readln return value in the EOF case

Status
NEW
Severity
enhancement
Priority
P4
Component
phobos
Product
D
Version
D2
Platform
All
OS
All
Creation time
2021-04-25T12:42:37Z
Last change time
2024-12-01T16:38:47Z
Assigned to
No Owner
Creator
kdevel
Moved to GitHub: phobos#10464 →

Comments

Comment #0 by kdevel — 2021-04-25T12:42:37Z
https://dlang.org/phobos/std_stdio.html#.File.readln does not define what the function returns in case of EOF. Only the code example // Reads `stdin` and writes it to `stdout`. import std.stdio; void main() { string line; while ((line = stdin.readln()) !is null) write(line); } suggests that a special string is returned which "is" null in that case. Some design have been discussed back and forth [1]. But it seems that the actual sentinel value is not null [2] but "" (the empty string). Can this be made explicit both in the section "Return value" and in the example? [1] <http://forum.dlang.org/post/[email protected]> Re: Empty VS null array? [2] This null value is not defined anywhere where it should be: <https://dlang.org/spec/arrays.html>
Comment #1 by robert.schadek — 2024-12-01T16:38:47Z
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/phobos/issues/10464 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB