Re: Small feature request for future EU versions

new topic     » goto parent     » topic index » view thread      » older message » newer message

On Sun, 17 Oct 2004 04:46:14 -0700, irv mullins <guest at rapideuphoria.com>
wrote:
> string and numeric comparisons? Several other languages do that
> without any problem.
> 
> Irv

The problem is this:

constant 
atom1=5,
atom2=10,
seq1={1,5,2,4},
seq2={1,2,5,4}

constant cond1 = ( atom1 = atom2 )
constant cond2 = ( seq1 = seq2 )

--cond1 will be 0, as 5 does not equal 10.
--cond2 will be {1,0,0,1}, because Euphoria compares each element.

The problem is that the IF statement doesn't know what to do with a
sequence, and there's not an obvious solution.
As a quick hack, lets say that if the IF statement receives a
sequence, it treats it as true if every element is non-zero.

That would allow us to easily compare strings using the simple form:
if string1 = string2.
However, what if the sequence passed to the IF statement is empty?
What if the sequence contains multiple levels?
What if the sequence contains a mix of non-zero integers, and an empty sequence?

I think that these things aren't easily solved...
Maybe it should be extended partially.
1. Only atoms, and 1-dimensional sequences can be passed to the IF statement
2. If an atom, pass if non-zero.
3. If a sequence, pass if all elements are non-zero.
4. If an empty sequence is passed to the if statement, treat it as a
'zero', I suppose.

What do you think of this solution?
I really don't like the idea of adding extra relationship operators.
:=, =>, ==, etc, is really annoying to remember. Trust me, I've
written too much VHDL code...

At least with the above suggestion, there's no broken compatibility, a
common issue (Why can't I just use '=' to compare these strings?) is
fixed, and it's a logical solution.
-- 
MrTrick

new topic     » goto parent     » topic index » view thread      » older message » newer message

Search



Quick Links

User menu

Not signed in.

Misc Menu