lua-users home
lua-l archive

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


> Personally I think that self.something() / self.super.something()
> is clearer than 'something' implicitly coming out of the class's
> namespace.  A standardised object mechanism isn't likely to address
> such personal preferences.

I'm not much good at this OOP stuff. I think I was supposed to learn C++ 
many years ago, but I found that the size of C++, combined with its visual 
absurdity (aka unreadability), made me sceptical. The self-righteous tone 
of Mr Stroustrup's books (is it just me, or is his prose about as 
readable as Military Discipline Code?) just made it harder for me to want 
to bother. So I am learning "modern" OO with Lua,

I recently wrote a Lua function like this:


local function process(self,conn)
    self.mutex:lock() 
    self.count = self.count+1
    --some more housekeeping stuff
    self.mutex:unlock()

    self.handle(self,conn)
    conn:close()
   
    self.mutex:lock()
    --some more housekeeping stuff
    self.count = self.count-1
    self.mutex:unlock()
end


Ignoring the probably-crap use of sockets and mutices, and ignoring the 
ignorance of the coder himself....at leat from a syntactic point of view, 
I thought this was a model of clarity. "What is it about self that Sir 
does not find informative?"