lua-users home
lua-l archive

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


On 2012-11-04 3:04 PM, "Gavin Wraith" <gavin@wra1th.plus.com> wrote:
>
> In message <CAMb+DaWHZR5YN+LO6S=_kg8w+VBawPL0suwQ9mfe8MQ-iD_9Sw@mail.gmail.com>
> you wrote:
>
>
> >    2. How difficult is it to extend Lua to support new binary operators?
> >    Beyond defining the symbol, the associated metamethod name, the precedence
> >    relative to other operators, and left/right association, is there a lot
> >    more to it (notionally)?
>
> Stuff in ltm.c and ltm.h.
>
> RiscLua adds bit-twiddling operators &,|,^^,~,>>,<< . Sources at
> http://www.wra1th.plus.com/lua/zip/Luasrc.zip .
> Search on "#ifdef GCW_BIT" for relevant lines.
>
> --
> Gavin Wraith (gavin@wra1th.plus.com)
> Home page: http://www.wra1th.plus.com/
>

I guess you could do a crude pure Lua solution by adding __call to strings, which will call the first parameter's metamethods... So e.g. '-'m would do getmetatable(m).__unm(m).