1. RE: math operators

> Lucius Hilley wrote:
>  
> POWER
> I would love to see power(4, 5) become 4^5.
> I know that we wouldn't be able to get read of power()

YES! i prefer "^" but another alternative is "**" (like Ruby)

> BITWISE OPERATORs
> compare() become ==
> and_bits() become &&
> or_bits() become ||
> 
> or at least see them used as operators. Such as:
>   if (int1 and_bits int2) then
>     if (int2 or_bits int2) then
>     end if
>   end if
> But that wouldn't be backwards compatible. :(

again, yes!

but i agree with what's been said about this "|" symbol before, it's 
just too ambiguous looking.
 
alternatives:    compare could be "~", but "==" is better
                 and_bits ---> "&and"
                 or_bits ---> "&or"
                 xor_bits ---> "&xor"

> also there is modulo and integer divide
> 
> MODULO
> I've always thought it odd that we didn't have a modulo
> operator.  We have remainder().  Why not have (5 % 3)
> or  (5 mod 3) or even (5 modulo 3)

the only problem with modulo is that it's sometimes NOT a well defined 
function. go to Dr. Math and you'll see that there are several 
definitions of modulo 
(http://mathforum.org/library/drmath/view/52343.html).

however, i agree with the missing operator sentiment (and i like the "%" 
symbol). 

i hereby respectfully request Rob to include the function as a built-in. 
all Rob has to do is define what the parameters of his built-in function 
are if they aren't _standard_.

> INTEGER DIVIDE
> We have floor(5/3).  Is 5\3 just too confusing?
> I like % for modulo because it looks like a fancy divide.
> Look at this.
> 5%3 -- remainder - modulo
> 5/3 -- divide
> 5\3 -- integer divide
> 
> They all are related and they all look similiar.

once again, very good thinking. to combine the divide and floor would 
certainly get my attention.


--
jon

new topic     » topic index » view message » categorize

2. RE: math operators

> compare() become ==

I meant equal() become ==

if ("this" == "this") then -- TRUE
  puts(1, "TRUE\n")
end if


        Lucius L. Hilley III

new topic     » goto parent     » topic index » view message » categorize

3. RE: math operators

> Lucius Hilley wrote:
> 
> BITWISE OPERATORs
> compare() become ==
> and_bits() become &&
> or_bits() become ||
> 
> or at least see them used as operators. Such as:
>   if (int1 and_bits int2) then
>     if (int2 or_bits int2) then
>     end if
>   end if
> But that wouldn't be backwards compatible. :(

oh, another alternative could be 
         and_bits ---> @and
         or_bits ---> @or
         xor_bits ---> @xor


--
jon

new topic     » goto parent     » topic index » view message » categorize

Search



Quick Links

User menu

Not signed in.

Misc Menu