[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: Proposal for a standard way of defining custom operators in Lua
- From: Leo Romanoff <romixlev@...>
- Date: Thu, 25 Jul 2013 13:04:28 -0700 (PDT)
----- Ursprüngliche Message -----
> Von: Tom N Harris <firstname.lastname@example.org>
> An: email@example.com
> Gesendet: 20:55 Donnerstag, 25.Juli 2013
> Betreff: Re: Proposal for a standard way of defining custom operators in Lua
> On Thursday, July 25, 2013 10:24:19 AM Leo Romanoff wrote:
>> We only want to add a few new lexemes to the language dynamically and
>> essentially it is the lexer that needs to be affected. And this is how I
>> envisioned a possible implementation. IMHO, this is a minimal required
> So you're talking about token filters? That patch, which is quite small, has
> been around for years with no sign of becoming standardized.
I dont' t know actually if this patch is capable of doing the required transformation.
In principle, it needs to be able to perform a transformation like this (I took an infix operator XYZ for this example):
Input: a operator_XYZ_token b
Output: metatable(a)[operator_XYZ_method](a, b)
Similar transformations would be required for prefix and postfix unary operators.
Also, it would be nice to be able to handle precedence and associativity of operators, otherwise it would be problematic to use them inside expressions containing more than one operator.
But I have no idea if a token filter or set of those can be used to achieve this goal. I read the PDFs about this patch, but I cannot directly see from there if it is possible or not with this filter-based approach. May be someone who has more experience with it can shed some light on this topic?