[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Proposal for a standard way of defining custom operators in Lua
- From: Leo Romanoff <romixlev@...>
- Date: Wed, 24 Jul 2013 08:50:19 -0700 (PDT)
>________________________________
> Von: steve donovan <steve.j.donovan@gmail.com>
>An: Lua mailing list <lua-l@lists.lua.org>
>Gesendet: 14:14 Mittwoch, 24.Juli 2013
>Betreff: Re: Proposal for a standard way of defining custom operators in Lua
>
>
>
>On Wed, Jul 24, 2013 at 1:43 PM, KHMan <keinhong@gmail.com> wrote:
>
>I agree, someone should try it out, offer a patch... The N3242 C++ draft was 1334 pages. I think Lua is very far behind in that respect and we need to catch up!
>>
>
>We'll never win, alas. They just keep growing ... but it would be nice to have new operators (say for bit operations) so we could overload them. (Some of these ways will be silly, but that's life)
>
>
>However, this proposal will not lead to a very efficient solution, and as Mr Highland points out, a language translator has to do that work anyway.
IMHO, the implementation will be as efficient as today's userdata types (e.g. C-based vectors or some OOP libs for lua) that overload e.g. the plus or minus operators. I'm not saying that current metatable dispatch is the best things in terms of performance, but it seems to be used by many Lua libraries.
Also, when talking about this feature we don't need to think about Lua only as a target language for translation. It would be nice to have some operators defined in Lua directly for the sake of convenience, e.g. bit operations that you mentioned or may be some IO operators. Some other operators could domain specific, e.g. send/receive operators for actor-like libraries, etc.
> Moonscript is a good example of a language that uses Lua - and for a certain value of identity, _is_ Lua with a new skin.
I agree. It is actually a good example. That fact that a lot of people like Moonscript indicates that Lua may seem to verbose or too unexpressive for some people. But Moonscript introduces a whole new language and totally new syntax.
My goal is to introduce a single and rather small building block that can be used e.g. to define new DSLs, but also for many other things. It does not require that a developer starts using a new language with all its features if she only wants to define a few operators, but otherwise stay with Lua.
-Leo