lua-users home
lua-l archive

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


I wonder if that two-iterator approach (which is a standard way of detecting loops in graphs), even if it might work, might force all users to pay an additional price (overhead of the additional iterator) in the case where there are no loops, which I would assume is the most common case.

On Fri, Jul 22, 2022 at 8:53 AM Roberto Ierusalimschy <roberto@inf.puc-rio.br> wrote:
> Currently loops in the __index lookup are detected by restricting the
> lookup to a depth of 2000.
> This can be removed by detecting loops instead of using a depth.
> Using two iterators traversing the __index lookup chain. Therby one is
> faster (in this case twice) as the other.
> In case there is a loop the faster one will at some point catch up to the
> slower one. If this happens a loop was detected and an error can be raised.

Would you mind explaining this idea more clearly?

-- Roberto