D (The Programming Language)/d2/Hello, World!/More Info about the Write Family

More Info about the Family
The four functions in the  family in   are:  ,  ,  , and. They are based on the C functions from cstdio (the D bindings to them are in ) for writing to streams. This subpage assumes that you have solid knowledge of the C standard library.

The  module imports , thereby gaining access to a stream named. Most of the time,  is the console, and it is most often line-buffered, even though the type of buffering is actually implementation-defined. So, line-buffering for  will be assumed for the rest of this article, even though it is not standard.

Map of What Happens

 * I. Start here if you are using .  For each argument that   is called with: goto A. with that argument.
 * A. If the argument is of some string type: goto 1. Else: goto B.
 * 1. If the argument is a  string and  : the argument will be passed to   to be written to , flushing will occur if the buffer is full, and maybe if there is a newline in the argument (especially on Linux).  Else: goto 2.
 * 2. Each character from the argument is written to stdout by being passed to either  or , depending on whether the character's type.  If the buffer becomes full or if the argument is a newline character, flushing will occur.
 * B. The argument is not of some string type. goto 1.
 * 1. If the argument is some char type: goto I.A.2.  Else: goto 2.
 * 2. The argument will be converted to a  string with , goto I.A.1.


 * II. Start here if you are using .  goto A.
 * A. If there are no arguments: Use  to output a newline to  . Flushing will occur. Else: goto B.
 * B. If there is one argument and that argument is a  (string) value: use   to print out that string with a newline at the end, and flushing will occur.  Else: goto C.
 * C. If there is more than one argument, or if there is only one argument that is not a string value: Add the char value of '\n' to the end of the arguments list, and then for each argument: goto I.A. with that argument.


 * III. Start here if you are using .  goto A.
 * A. If the first and only argument is a : goto I.A.2. with that argument.  Else: All the arguments are formatted (C-style) together with , and goto I.A.1. with that result.


 * IV. Start here if you are using .  goto A.
 * A. If the first and only argument is a : goto I.A.2. with each of these two: (that argument, a newline  ).
 * Else: All the arguments are formatted (C-style) together with, and goto I.A.1. with each of these two: (the result from formatting, a newline  ).