[Issue 21860] New: readln return value in the EOF case

d-bugmail at puremagic.com d-bugmail at puremagic.com
Sun Apr 25 12:42:37 UTC 2021


          Issue ID: 21860
           Summary: readln return value in the EOF case
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: enhancement
          Priority: P1
         Component: phobos
          Assignee: nobody at puremagic.com
          Reporter: kdevel at vogtner.de

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)

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

    Re: Empty VS null array?

[2] This null value is not defined anywhere where it should be:


More information about the Digitalmars-d-bugs mailing list