Re: Number comparison gotcha

Bill Frantz <[email protected]>
Newsgroups gmane.comp.lang.e.general
Message-ID <r314ps-1066i-D9402CA42741496DA8DE0A36AB26EEB4@Bill-Frantzs-MacBook-Pro.local>
On 1/25/11 at 5:37 PM, [email protected] (Mark S. Miller) wrote:

>This highlights the difference between computational equivalence (==) and
>"same magnitude" (<=>). In E, the <=> operator is a peer with <, <=, >=, and
>>. Unlike ==, for all five of the magnitude comparison operators, the
>request is made to the left operand with the right operand as argument. The
>answer is according to the left operand. For operands that satisfy the
>contract, x <=> y iff x <= y && x >= y. So:
>
>? 5000 <=> 5000.0
># value: true

This is well documented in 
<http://www.erights.org/elang/scalars/float64-ref.html> (which I 
finally found. I added a link to the top of the elang 
documentation in 
<http://wiki.erights.org/wiki/Documentation#Tutorials_and_References>) 
so I might be able to find it again. If there is a wikified 
version of the elang documentation, I need to update this link.

What is the name of the message the <=> operator sends? (Is it 
valid for integers/booleans/characters?) It's not described in 
the table of magnitude operations for float64 in the above web 
page, but seems to be described on 
<http://www.erights.org/elang/grammar/expr.html>. When I tried 
defining "to compareTo()" which, in my implementation, returned 
an integer, I got:

#   - Comparer#asBigAs(Object, Object)
#   . <a Comparer>.asBigAs(<***an EImplByProxy throws a 
NoSuchMethodException when printed***>, <***an EImplByProxy 
throws a NoSuchMethodException when printed***>)
#   @ asBigAs/2: </Users/frantz/Caving/Table Mountain Talus Area/DataMerge/dateck.e#:span::183:11::183:13>

when I tried to use <=>.

All of this is because I gave up trying to use the Java Date 
class and its seemingly infinite number of "helper" classes, all 
of which had voluminous documentation to wade through and didn't 
seem to do what I want.

Since my Date object could be selfless 
<http://www.erights.org/elang/same-ref.html>, but that web page 
indicates that the selfless system hasn't been implemented yet, 
getting <=> to work seems like the next reasonable step.

Cheers - Bill

-------------------------------------------------------------------------
Bill Frantz        | When it comes to the world     | Periwinkle
(408)356-8506      | around us, is there any choice | 16345 
Englewood Ave
www.pwpconsult.com | but to explore? - Lisa Randall | Los Gatos, 
CA 95032
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.