lua-users home
lua-l archive

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


On Thu, Mar 4, 2010 at 8:05 PM, David Manura <dm.lua@math2.org> wrote:
>  function one() return pcall(loadstring, s) end
>
> Here, the "caller" is not `one` but rather `pcall`, which has an
> environment of `_G`.  Granted, this problem would be at least reduced
> if the function `pcall` were replaced with an actual keyword in the
> language, as John Belmonte et al have been advocating [4,5], but I
> don't think that alone addresses the real problem here.  Utilizing the
> "environment of the caller", or any call stack levels, is really a
> type of dynamic scoping, and we should ask whether that is really what
> we want.  (The Lua `module` function does likewise, and I'm glad that
> aspect is deprecated in 5.2 [6].)  Dynamic scoping in the form of
> tying environments to call stack frames, as Mark Hamburg suggested
> [10], may avoid the above problem since `pcall` would no longer have
> the environment `_G`, but let's ignore that for now.

Oof, good point. =/

~Jonathan