[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: OOBit
- From: Petite Abeille <petite.abeille@...>
- Date: Wed, 29 Sep 2010 23:25:00 +0200
On Sep 29, 2010, at 10:39 PM, Peter Sommerfeld wrote:
> There are no confusing similar concepts. Dot is "get value" and
> colon is "call". Easy to grasp, isn't it?
Yes, yes, just sugar... but still... at first glance... OMG!
local aTable = { dwim = function( self ) print( self ) end }
aTable[ 'dwim' ]( aTable )
aTable:dwim()
aTable.dwim()
> table: 0x1001058e0
> table: 0x1001058e0
> nil
WTF?!? :P
To further confuse matters...
local aTable = setmetatable( {}, { __index = function( self, key ) return function() print( self ) end end } )
aTable.dwim()
> table: 0x1001058e0
To paraphrase
Programming in Lua
Part II. Tables and Objects
Chapter 12. Data Files and Persistence
http://www.lua.org/pil/12.1.2.html
"Lua gives you the power; you [choose how to hang yourself]" :P