Empty VS null array?

Jonathan M Davis jmdavisProg at gmx.com
Fri Oct 18 10:32:58 PDT 2013


On Friday, October 18, 2013 09:55:46 Andrei Alexandrescu 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.

Yeah, but the primary reason that it's bad design is the fact that D tries to 
conflate null and empty instead of keeping them distinct (which is essentially 
the complaint that was made). Whether that's ultimately good or bad is up for 
debate, but the side effect is that relying on the difference between null and 
empty ends up being very bug-prone, whereas in other languages which don't 
conflate the two, it isn't problematic in the same way, and it's much more 
reasonable to have the API treat them differently.

- Jonathan M Davis


More information about the Digitalmars-d mailing list