On Fri, 18 Oct 2013 17:55:46 +0100, Andrei Alexandrescu
<seewebsiteforem...@erdani.org> wrote:
On 10/18/13 9:26 AM, Max Samukha wrote:
*That's* bad API design. readln should be symmetrical to writeln, not
write. And about preserving the exact representation of new lines,
readln/writeln shouldn't preserve that, pure and simple.
Fair point. I just gave one possible alternative out of many. Thing is,
relying on client code to distinguish subtleties between empty and null
strings is fraught with dangers.
My code does not need to distinguish between empty and null. null is
checked for, and empty is just a normal value for a string. The "problem"
you're referring to is /casused/ by conflating null and empty, by making
empty strings "special" in the same way someone might make 0 a special
value for an int (meaning not specified - for example).
If you stop using empty string as a special case of null, then empty does
not need special handling - it's just a normal string value handled like
any other - you can read it, write it, append it, etc etc etc.
null is the /only/ case which needs special handling - just like any other
reference type.
R
--
Using Opera's revolutionary email client: http://www.opera.com/mail/