Empty VS null array?
Max Samukha
maxsamukha at gmail.com
Fri Oct 18 10:59:16 PDT 2013
On Friday, 18 October 2013 at 16:55:19 UTC, Andrei Alexandrescu
wrote:
>
> 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.
>
> Andrei
I agree. Thinking about your variant of readln - it's ok to use
[] as the value indicating EOF, since it is not included in the
value set of type "line" as you define it. But generally, neither
cast(T[])[] nor cast(T[])null should be used like that, because
both of them are in the set of T[]'s values, i.e. a generic
stream returning [] to signify its end would be a bad idea - that
should be either a side effect or a value outside T[]'s set.
Hm, I've just said nothing with many words. Never mind.
More information about the Digitalmars-d
mailing list