[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: Generic optimizable operation syntax proposal
- From: Sergey Zakharchenko <doublef.mobile@...>
- Date: Sat, 4 Jun 2022 13:04:20 +0300
> So if I understand the proposal, it's an indication to the Lua parser that
> if it understands an expression, it should optimize it? For example, if
> this had been in Lua 5.2, and I wrote:
> x = `(bit32.band(a,b))
> then in theory, if an extension to Lua added the '&' operator, then it could
> be rewritten (by the parser) as:
> x = a & b
> Am I close here?
Correct. Even better, it could rewrite it to x = a <noncharacter token
meaning &> b, and there would be a way to avoid collisions.
> Or is it a way to prevent side effects from potential monkey patching?
No. Like I mentioned, the parser should have some way to specifically
opt into this. If you e.g. patch 'type' to return "table" instead of
"userdata", or if the code itself does this and can get away with it,
all bets are off, so this is for trusted code and/or environments