[cap-talk] Lua, Javascript, and the Object Capability Model

Tony Finch dot at dotat.at
Tue Jul 28 07:45:30 EDT 2009


On Tue, 28 Jul 2009, David-Sarah Hopwood wrote:

> Tony Finch wrote:
> > On Mon, 27 Jul 2009, Matej Kosik wrote:
> >>
> >> (1) Can the first subsystem pass a reference to its private object to
> >> another subsystem as a parameter to a function call?
> >>
> >> (2) Can the second subsystem return a reference to its private object to
> >> the first subsystem as a return value?
>
> > You can also implement objects in Lua as closures, in which case the
> > answers are no, in both cases.
>
> Why not? I wasn't aware of any restrictions on the "first-classness" of
> closure values in Lua.

Perhaps I mis-interpreted the meaning of "private object". I thought it
meant the private parts that should be insulated from the rest of the
program. In Lua there are various fiddly techniques you can use (already
outlined in this thread) to insulate an object's underlying table from the
rest of the code, but an untamed ref can still leak out. If the object is
based on a closure then you don't need to do any explicit taming, and you
can't leak direct access to the private variables.

Tony.
-- 
f.anthony.n.finch  <dot at dotat.at>  http://dotat.at/
GERMAN BIGHT HUMBER: SOUTHWEST 5 TO 7. MODERATE OR ROUGH. SQUALLY SHOWERS.
MODERATE OR GOOD.


More information about the cap-talk mailing list