[E-Lang] Operators #6: Multiplicative operators

Mark S. Miller markm@caplet.com
Mon, 09 Apr 2001 10:13:14 -0700


--=====================_64953697==_.ALT
Content-Type: text/plain; charset="us-ascii"

At 02:09 AM Monday 4/9/01, Tyler Close wrote:
>What are the arguments against giving integer/ the first definition and 
>banishing the "_/" operator? Why do integers need to exhibit float-like 
>behaviour? They are a different data type.

As Dean has argued, perhaps I'm taking the Java precedent too seriously.  I 
didn't want to introduce operators that usually seemed identical to the Java 
operators but weren't.  Remember that one of E's uses is as a command shell 
for the Java platform.  This subtle change could lead to a lot of head 
scratching.

If I stopped taking this issue seriously, and if current and potential users 
are not put off by the disruption, I'd propose:

    x / y      ->  x op__div(y)
    x % y      ->  x op__mod(y)    

Where op__div on integers is a floor divide (round towards negative 
infinity, ie, the largest integer not greater than the true quotient), 
rather than Java's stupid truncating divide (round towards zero).  "%" would 
expand to op__mod and so, on integers, be the remainder from floor divide, 
and therefore a true modulo.  Modular exponentiation would then be written as

    x ** y % z

I would still have integers respond to the current "truncDivide" and 
"remainder" messages, which correspond to Java's meanings for "/" and "%".  
Perhaps "remainder" should be renamed "truncRemainder" to emphasize the 
correspondence.  


How seriously should I take the above issue: reuse of an existing Java 
operator with an only subtly different meaning?  Also, given the recent news 
from openCOLA, we need to ask: Is this a change we need to make?  Awaiting 
reactions.


        Cheers,
        --MarkM

--=====================_64953697==_.ALT
Content-Type: text/html; charset="us-ascii"

At 02:09 AM Monday 4/9/01, Tyler Close wrote:
What are the arguments against giving integer/ the first definition and
banishing the "_/" operator? Why do integers need to exhibit float-like
behaviour? They are a different data type.

As Dean has argued, perhaps I'm taking the Java precedent too seriously.  I
didn't want to introduce operators that usually seemed identical to the Java
operators but weren't.  Remember that one of E's uses is as a command shell
for the Java platform.  This subtle change could lead to a lot of head
scratching.

If I stopped taking this issue seriously, and if current and potential users
are not put off by the disruption, I'd propose:

    x / y      ->  x op__div(y)
    x % y      ->  x op__mod(y)   

Where op__div on integers is a floor divide (round towards negative
infinity, ie, the largest integer not greater than the true quotient),
rather than Java's stupid truncating divide (round towards zero).  "%" would
expand to op__mod and so, on integers, be the remainder from floor divide,
and therefore a true modulo.  Modular exponentiation would then be written as

    x ** y % z

I would still have integers respond to the current "truncDivide" and
"remainder" messages, which correspond to Java's meanings for "/" and "%". 
Perhaps "remainder" should be renamed "truncRemainder" to emphasize the
correspondence. 


How seriously should I take the above issue: reuse of an existing Java
operator with an only subtly different meaning?  Also, given the recent news
from openCOLA, we need to ask: Is this a change we need to make?  Awaiting
reactions.


        Cheers,
        --MarkM
--=====================_64953697==_.ALT--