RE: RE: if statement not working
- Posted by bensler at mail.com Mar 21, 2002
- 411 views
You're quite right :) The relational operators map directly to the various compare() scenarios. It wouldn't make much sense to introduce a new delimiter to the language. I've always been trying to think of an alternate operator because I have assumed that there is some underlying reason why relations only work for numeric expressions. I've pointed out the only 2 I can come up with in an earlier post. While it's great that we can compare the equality of sequences of similar structure, it breaks from logic to support it that way. It's only logical that relational operators work on all euphoria objects, just like regular operators. It makes more sense for equal() and compare() to return objects, than for conditional operators to break from their boolean tradition. Until today, I didn't even know I could use = with sequences at all. It just doesn't make sense. Chris Derek Parnell wrote: > 22/03/2002 12:43:00 PM, bensler at mail.com wrote: > > > > >I like the fact that = only works for numeric comparison. > >I'd like to see == for object comparisons though, instead of equal() > > > >Chris > > Why? What problem is having two sets of comparitors solve? > > Are you suggesting for numbers we use: = > < != <= >= > and for sequences we use: == >> << !== <== >== > > If want to know if one sequence has the same value as another, why is it > better that I use "==" > instead of "="? > > It even introduces another issue that the current Euphoria doesn't have. > > Currently I can write: > > atom x > sequence s > > if equal(x,s) then ... > > but your suggestion I'd use: > > if x == s then ... > > but what happens if I later change my mind and 's' is now an integer. I > have to go and update all my > comparitor references to use '=' etc... Is this a better idea? I think > not. > > --------- > Derek. > >