lua-users home
lua-l archive

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



Roberto Ierusalimschy kirjoitti 17.2.2009 kello 20:14:

I do not see why the need for the <scoped_statements>. It would be
simpler to add only a new form of locals. Something like

local finalized f, g = ...

that calls ":close()" (or __gc??) when it goes out of scope.  Of
course,
you can (should?) use a conventional do-end around it:

And all of that can easily be done using token modifiers.

Case solved?  :)

I do not see how this can be done with token modifiers, if we want to
handle exceptional exits too.

-- Roberto


Yes, you are right. Token modifiers would cope with the normal exits (break/return/end of scope) but they couldn't "see" an error happening in some called function, for example. Not without a pcall.

As to the coroutine issue, would it be valid to just say a coroutine switch (yield/resume) is not allowed to take place within a finalizable scope. Would that be too restricted in practice? If not, then the coroutine problem vanishes.

I do have one working solution to this, which is the Lanes approach. But I know it's not the generic answer.

-asko