Checking if a string is null

Bruno Medeiros brunodomedeiros+spam at com.gmail
Thu Jul 26 18:11:59 PDT 2007


Manfred Nowak wrote:
> Bruno Medeiros wrote
> 
>> Monoids and other common mathematical structures do not have the
>> notion of computer-science identity, only equality (which they may
>> call identity, but it's the same as equality in a programming
>> languages context). 
> 
> From your signature follows that you might at least understand the 
> theoretical background.
> 
> 
> The mathematical equality relation `=' is a special case of the 
> mathematical equivalence relation `~' in that "two mathematical 
> objects are equal if and only if they are precisely the same in every 
> way" [cited from wikipedia].
> 
> I.e. in D the mathematical equality relation is bound to the 
> identityExpression and restricted to arrays containing at least one 
> element.
> 

Ok, if you apply the definition of the mathematical equality relation to 
raw program-objects, then yes, the mathematical equality relation is 
bound to the identityExpression. However, doing that is quite dubious 
and useless. (I'll explain better in another post)
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. An identity relation exists for any array pair (of 
the same type at least).

> 
> To D's equalityExpression only a mathematical equivalence relation is 
> bound and also restricted to arrays containing at least one element, 
> as one can see from the definition:
> 

Ok, I understand what you mean by saying that the equalityExpression is 
  only a mathematical equivalence relation, but again I don't understand 
what you mean by saying that it is restricted to arrays containing at 
leas one element.

> | For static and dynamic arrays, equality is defined as the lengths
> | of the arrays matching, and all the elements are equal.
> 

Again I don't see why this means it is restricted to arrays containing 
at least one element.

> I.e. for two arrays `a' and `b' declared as `T[] a, b;' for some type 
> `T' having at least one element each, holds:
>    if `a is b' then `a == b'
> But the other direction is not necessarily true.   
> 
> 

Huh? That property "if `a is b' then `a == b'" holds for arrays with 
zero elements as well. In fact it hold for *any* type (that has a well 
defined equality operator).

-- 
Bruno Medeiros - MSc in CS/E student
http://www.prowiki.org/wiki4d/wiki.cgi?BrunoMedeiros#D



More information about the Digitalmars-d mailing list