Re: Strings and the like.
- Posted by Irv Mullins <irv at ELLIJAY.COM> Dec 09, 1999
- 514 views
On Thu, 09 Dec 1999, Everett Willaims wrote: > At last some meat and potatoes. I NOW see the equal function. Somehow, > I had missed it previously. I still don't see the need for it. The highest > level > comparison is the natural one, all others should be handled either implicitly > or by function where functions return values. In the syllogism, logic is > binary. The equal sign means equivalence. It does not deal with values. > It deals with the path to be followed. It is a switch set by the values on > either side of it. There is no problem when a function returns multiple > values in a sequence. That is consistency. The equal sign as assignment > operator deals with values. It creates no inconsistency when it allows > multiple values to be assigned. When multiple values are returned by > an equivalence that "can" have and demands a single value, consistency is > not served. It is not difficult for the interpreter to distinguish situations > where a single value is required. There is no inconsistency or programmatic > problem when comparing any two values or sets of values in a structure as > long as both the structure and the values are equivalent. But, they are > either equal or unequal, true or false, then or else. Now this is an actual problem, which is a source of confusion in the beginning, and a continuing aggravation thereafter. Why, indeed, shouldn't the = within an 'if a = b then...' construct return a true/false result, computed as follows: 1. if the lengths are different, return false 2. if every byte of a = every byte of b, then return true else return false In part, this would help achieve a kind of symmetry within the language: a = 5 if a = 5 then.... b = "Bill" if b = "Joe" then.... nope, no need for an error, Bill will never equal Joe if b = 5 then.... ditto. For the rarer case when we actually need a byte-by-byte comparison returned - (somebody suggest an appropriate keyword) a = "Bart" b = "Bill" ? coincidence(a,b) returns: {1,0,0,0} Regards, Irv