[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: What are the use cases of in-do-end?
- From: GrayFace <sergroj@...>
- Date: Wed, 27 Jan 2010 19:24:42 +0600
So far I've read mentions of several use cases, but I don't understand
how exactly it may be useful in them. Here's what I read about:
1) Obvious usecase: something like Deplhi's 'with'. This is not the main
use case Lua developers targeted, for sure. Inability to call global
functions, a need for additional local variable to call methods makes
2) Modules. Maybe it's due to the fact that I didn't work with modules,
but I don't see it useful. I don't see a reason for setting current
environment like 'module' does in 5.1 or use of in-end of 5.2 due to the
same reason: inability to call global functions. Generally, I'd prefer
to directly write "function P.f() end" instead of "function f() end"
given P is the module table.
3) Sandboxing. I did sandboxing with setfenv and can only think of doing
it with setfenv or loadin. How can in-end help with it?
4) Some strange use cases of setfenv. What I've read made me feel like
either setfenv or in-end is used in a wrong way. For example, here
in-end is used in a wrong way:
5) Something else?