lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]

> On 2016-06-09, at 3:24 PM, Egor Skriptunoff <> wrote:
> Currently, there is no assurance that the symbol "+" in Lua program will invoke the addition user implied and not the other addition.
> I can't come up with a good idea how to solve this.
> Non-7-bit-ASCII symbols for operations is a bad idea.
> Using "[+]", "(*)" or other complex symbols for integer operations is a bit awkward.
> Using bit64 library will make integer operations boring to use.

The default could be picked for whole blocks. So along with

  i = j [*] 2
  n = n [+] i

create new syntax to declare what operators mean inside a block:

  option math=integer do
    i = j * 2
    n = n + i

I am not thrilled with this, but I've considered a similar facility to allow code to opt-in to making the ".." operator be utf8-safe.