lua-users home
lua-l archive

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


Regarding the function signature of scope exit:  since it's possible to throw value nil it seems like it will have to be (success, error_value).

On Sat, Jul 21, 2018 at 11:22 PM, John Belmonte <john@neggie.net> wrote:
In the generic for statement pseudocode, could explist return a 4th, optional result which is assigned to a scoped variable?  I assume a scoped var with value nil is a no-op on exit.

    do
       local f, s, var, exit_f = explist
       local scoped _exit_f = exit_f
       while true do
         local var_1, ···, var_n = f(s, var)
         if var_1 == nil then break end
         var = var_1
         block
       end
     end

On Sat, Jul 21, 2018 at 7:55 PM, Roberto Ierusalimschy <roberto@inf.puc-rio.br> wrote:
> >From the land of PEP: deterministic cleanup for iterators
>
>   https://www.python.org/dev/peps/pep-0533/
>
> Can the prospective scoped locals be applied to this use case?

No. The proposed 'with' clause also does not seem to apply :-)

-- Roberto