Warning: this is an htmlized version!
The original is here, and
the conversion rules are here.
-- This file:
--   http://angg.twu.net/LUA/pil3_16.lua.html
--   http://angg.twu.net/LUA/pil3_16.lua
--           (find-angg "LUA/pil3_16.lua")
-- Author: Eduardo Ochs <eduardoochs@gmail.com>
--
-- (defun e () (interactive) (find-angg "LUA/pil3_16.lua"))


-- (find-books "__comp/__comp.el" "ierusalimschy")
-- (find-pil3page (+ 19 163) "16 Object-Oriented Programming")
-- (find-pil3text (+ 19 163)    "Object-Oriented Programming")


--[[
* (eepitch-lua51)
* (eepitch-kill)
* (eepitch-lua51)
dofile "pil3_16.lua"

Account = {balance = 0}
function Account.withdraw (v)
  Account.balance = Account.balance - v
end

Account.withdraw(100.00)

a, Account = Account, nil
a.withdraw(100.00)      -- ERROR!


function Account.withdraw (self, v)
  self.balance = self.balance - v
end


a1 = Account; Account = nil
...
a1.withdraw(a1, 100.00)   -- OK

a2 = {balance=0, withdraw = Account.withdraw}
...
a2.withdraw(a2, 260.00)



function Account:withdraw (v)
  self.balance = self.balance - v
end

a:withdraw(100.00)

Account = { balance=0,
            withdraw = function (self, v)
                         self.balance = self.balance - v
                       end
          }
function Account:deposit (v)
  self.balance = self.balance + v
end

Account.deposit(Account, 200.00)
Account:withdraw(100.00)

--]]






-- (find-pil3page (+ 19 165) "16.1 Classes")
-- (find-pil3page (+ 19 166) "16.2 Inheritance")
-- (find-pil3page (+ 19 168) "16.3 Multiple Inheritance")
-- (find-pil3page (+ 19 170) "16.4 Privacy")
-- (find-pil3page (+ 19 172) "16.5 The Single-Method Approach")