Re: Short Circuit
David Cuny writes:
> Euphoria allows logical and comparison binary operators
> to return sequences. For example:
> and
> or
> =
> In the case of some operations, this is sensible.
So you'd like to break the simple orthogonality of binary operators,
and introduce a bunch of exceptions, that people will have to
remember, into the language definition.
> (1) The '=' comparison is worthless. You can only
> compare sequences that are *exactly* the same in structure,
> with exactly the same lengths, down to the last nested subsequence.
Wrong. Try:
? {1,2,3} = {{1,1,1}, {0,0,0}, {3,2,1}}
> I challange anyone to find me an example where this is
> actually useful, other than for performing obscure tricks
> with bitmaps.
global function upper(object x)
-- convert any atom or sequence (of any complexity) to upper case
return x - (x >= 'a' and x <= 'z') * TO_LOWER
end function
> (2) Even if the behavior was useful, you *still* need
> to build a loop to scan through the results.
How about:
find(1, "ABC" = "aBc")
> (4) The '=' operator doesn't work the way people want it to
You mean it doesn't work the way that Basic people expect.
C people and others would not expect to compare
strings using '='. In C they happily use strcmp().
> (5) Short-circuiting should be consistant.
The fact that there would be a small inconsistency
when short-circuiting was introduced 2 years ago,
was discussed at that time. No one seemed concerned about it.
The alternatives were to:
a) not have short-circuiting at all
b) break a lot of code
c) introduce special new and/or short-circuit operators that:
- few would bother using
- that wouldn't speed-up existing code
- which would confuse people since most of the
time they'd be equivalent to 'and' and 'or'
Up until now I've only had a few complaints that
short-circuiting only applies in conditional expressions,
not all expressions.
> (1) Change the behavior of '=' so it acts like 'equal'.
> It (and it's kin) only return boolean integer values.
Far too much breakage of existing code.
Breakage may not bother someone like yourself
who is aware of the changes from one release of Euphoria
to another. You can go back and correct any
of your own code, and other people's code in include files
that you use. But what about the Archive of almost 700 programs?
What about the less informed people out there who suddenly find
that their program is failing or behaving strangely, and start sending
me tech support requests for the next N years? People want their
existing programs to work. They don't want to have to search
through old code for statements that are not aesthetically pleasing
to David Cuny.
Regards,
Rob Craig
Rapid Deployment Software
http://www.RapidEuphoria.com
|
Not Categorized, Please Help
|
|