[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: boolean operators
- From: Rici Lake <lua@...>
- Date: Wed, 27 Sep 2006 15:10:45 -0500
On 27-Sep-06, at 1:30 PM, Glenn Maynard wrote:
Lua provides its standard libraries to avoid this; add math.idiv and
math.imod.
Sure, but those are not cleanly overrideable if I want to implement, for
example, bignums.
"If it has this, it must have this too" seems empty. If it's really
useful, you can argue for it on its own, independent merits. If it's
not justified on its own merits, then "symmetry" is a bad reason; it's
saying "do it because it looks good".
Syntax is largely about "looks good", so I don't regard that as a
completely empty argument.
I'm not suggesting // in order to make it easier to interface with C
integers -- I'm suggesting it because I would use it a lot if it
existed. Try doing calendric calculations without it, for example.
Admittedly, modulo/remainder is slightly more common, but the two
operators do go together in an essential way (as part of a numeric
suite, not as part of a hack to make integers look like bitstrings).
The bitstring library I use overrides + for 'or', '*' for 'and'
and unary minus for 'not'. I actually use those as bitstrings, not
integers, so that works well for me. If Lua had 'inf' and 'sup'
operators, I would have used those instead; I think that would
be clearer. There are advantages and disadvantages to overriding
operators, but it is clearly part of Lua, and the ability to
override numerical operators is presumably in order to allow the
implementation of number-like objects, like bignums, continued
fractions, complex numbers, or whatever. In that context, once the
decision is made to implement %, which I have no problems with, it
seems reasonable to me to implement the other half of that operation,
euclidean division.