Checking if a string is null

Frits van Bommel fvbommel at REMwOVExCAPSs.nl
Fri Jul 27 02:07:55 PDT 2007


Manfred Nowak wrote:
> *** superseeding previous post ***

You should be able to delete ("cancel") your own posts...

> 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.

I don't see this as informal or different from your version in any way 
but verbosity.

> 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"

The fact that the spec doesn't seems to mention when two arrays compare 
equal doesn't mean two empty arrays don't compare equal. Obviously, 
equal arrays compare equal (regardless of the number of elements). Empty 
arrays are equal to other empty arrays.

> Note: maybe definition _and_ implementation are both buggy :-(

The definition is "buggy" in that it only mentions when arrays compare 
non-equal, not when they compare equal. The implementation is fine.

>> 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.

Yes, we get it. The specification forgot to explicitly mention when 
arrays compare equal. (Hint: it's when they're *EQUAL*)



More information about the Digitalmars-d mailing list