[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: file proxy?
- From: Per Bull Holmen <pbholmen@...>
- Date: Fri, 12 Feb 2010 04:37:59 -0800 (PST)
spiro wrote:
> I'm looking for a way to "subtype" Lua files, for file objects to hold
> additional attributes. It seems I cannot directly set attributes on
> Lua Files, since they are userdata. Is there a way to write a custom
> file type that delegates file methods to an actual Lua file (open in
> mode 'r')? My trials using __index with a table or function launch
> errors like:
Perhaps you can write your factory function so that each new instance contain the corresponding Lua file (hold a reference to it), rather than deriving from it? Then your __index function could replace self with the reference to the original file.