[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Can C code recognize, whether Lua inside some loop/block? (for/while/repeat/if)
- From: Flyer31 Test <flyer31@...>
- Date: Wed, 16 Feb 2022 13:04:40 +0100
Hi Roberto,
thank you for this further warning ...
If you have some other idea how to solve this in a very "RAM saving"
method, then nice.
But generally such IoT main loops, where all the inputs are checked,
are VERY boring code... It is no real restriction to exclude any loop
/ block possibilities there, and also no goto ... label constructions,
you are completey right.
(and I also present a dynamic version of this function, which can then
be used in such cases...).
On Wed, Feb 16, 2022 at 10:43 AM Roberto Ierusalimschy
<roberto@inf.puc-rio.br> wrote:
>
> > In general, you cannot [1]. In particular, there is no way to detect if
> > Lua is executing within a loop. The following Lua code:
> >
> > [...]
>
> Not to mention optimizations, gotos, and other strange constructions:
>
> - if x then return end
> FOO()
>
> Syntactically, the call is not inside an 'if', but semantically it is.
>
> - repeat FOO() until true
>
> Syntactically, the call is inside a loop, but semantically it isn't.
> (See the opcodes!)
>
> -- Roberto