Checking if a string is null

Manfred Nowak svv1999 at hotmail.com
Wed Jul 25 19:03:13 PDT 2007


*** previous Post superseeded ***

Bruno Medeiros wrote

> It's in
> http://www.digitalmars.com/d/expression.html#IdentityExpression
> "For static and dynamic arrays, identity is defined as referring
> to the same array elements"

>From the specs:
| Concatenation always creates a copy of its operands, even if one
| of the operands is a 0 length array 

I believe that these definitions are essential for solving the 
dectected ambiguities.

Their meaning is, that arrays together with the concatenation 
operation do not form the mathematical structure of a monoid, because 
there is no identity preserving element for arrays under the 
concatenation operation.

Moreover: concatenation is not associative either because identity is 
defined only for arrays containing elements, i.e. two arrays with a 
length of zero might not be identical.

What remains is the mathematical structure of a magma.

That is ridiculous :-(




Possible way to a solution of this:

1) Decide that all `arrayType's only contain arrays, i.e. no values 
for not-an-array.

2) For each `arrayType' define generically one neutral element for 
the concatenation operation. Call this element `arrayType.epsilon' or 
`arrayType.one'.

3) Define one neutral element for the (hypothetical) choice operation 
on arrays. Given an arbitrary `arrayType', this neutral element can 
be accessed by `arrayType.null'.

4) Extend the identityOperator to work correctly with the elements 
from 2) and 3).

5) Change the concatenation operator to preserve identity under 
concatenation with `arrayType.one'.  I.e. for some `a' declared as an 
array of `T' holds: `T.one ~ a is a' and `a ~ T.one is a'

6) Change the concatenation operator to interpret `arrayType.null' as 
a both-sided annihilator. I.e. for some `a' declared as an array of 
`T' holds: `T.null ~ a is T.null' and `a ~ T.null is T.null'

7) Change the assignment operator to interpret an assignment with 
`null' to be an assignment with `T.null', where `T' is of the 
appropriate type

8) For all `arrayType's declare generically:
  `arrayType.init= arrayType.null;'

9) Decide whether to declare `arrayType.null' to be unprintable


I hope that this list is complete.

-manfred  
 





More information about the Digitalmars-d mailing list