Checking if a string is null
Manfred Nowak
svv1999 at hotmail.com
Fri Jul 27 00:59:26 PDT 2007
*** superseeding previous post ***
Bruno Medeiros wrote
> But first, explain me this, what do you mean the
> "identityExpression is restricted to arrays containing at least
> one element."? That doesn't seem to make sense.
In at least most definitions for relations on arrays in D the phrase
"all elements" is used.
Besides the fact that this phrase is informal its meaning seems to be
different from "for all x in the set S: P(x)". This latter phrase
clearly binds the predicate P to elements in existence.
Such existence quantor seems not to be included in the phrase "all
the elements are equal". This impressions is supported by this code
fragment:
writefln( "" is ""); // prints "false"
The definition for the relationalExpression supports the restriction
I phrased most prominently:
| For static and dynamic arrays, the result of the relational op is
| the result of the operator applied to the first non-equal element
| of the array.
I.e.: if there is no element, then there is no first element, then
the result of the relationalExpression is not defined. According to
the definition it is a bug that this code fragment is compilable:
writefln( "" < ""); // prints "false"
Note: maybe definition _and_ implementation are both buggy :-(
> That property "if `a is b' then `a == b'" holds for arrays with
> zero elements as well.
Maybe that the implementation is holding this property. But the
specifications does not mention it. Therefore this property might not
be intended and the implementation is waiting for a case where this
property does not hold.
-manfred
More information about the Digitalmars-d
mailing list