lua-users home
lua-l archive

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

Penlight is the solution for me. It's really very simple to use and
supports a large number of nice features. Let's my first test:

class = require('pl.class')
dir = require('pl.dir')


function folder:_init(name)
filter = '*' = name

function folder:get_count()
local items = dir.getfiles(, filter)
return #items

function folder:set_filter(pattern)
filter = pattern

folder = folder('c:/fontes')
folder.filter = '*.exe'

Thank you for the indication. I really liked Penlight.

I hope the posting is correct. I am blind, I use screen reader. In the
Gmail page, there are several "reply" buttons. It's sometimes
difficulty to understand where the message will be. I used to access
by means of "alt+shift+r" and I don't know if this changes something.

2012/6/28, Henk Boom <>:
> On 28 June 2012 09:29, luciano de souza <> wrote:
>> Hello all,
>> I wasn't acquainted with OOP strategies in Lua. What I know is that we
>> have nice options like Classlib, Loop, LOS... and the raw handling of
>> metatables.
>> Supppose the following structure:
>> -- [[
>> class number
>> method GetValue
>> property value
>> ]] --
>> Now suppose the following function:
>> function number:GetValue()
>> return math.random(100)
>> end
>> I would like to do something like that:
>> number = number()
>> print(number.value)
>> The reply could be 80, 35, 44 or any randomic value between 0 and 100.
>> Using Classlib, LOOP or any other Lua library with OOP support, how
>> can I do this?
> Steve Donovan's Penlight library has a class implementation, and if
> you inherit from it will set up the metatable so that
> get_* and set_* are automatically called. It does have the unfortunate
> side effect that getters are automatically set up for variables
> starting with an underscore, which I find problematic because I often
> use _variables as pseudo-private fields.
>     henk