Strange behavour in Lua classes - 0.9.1

Nigel Atkinson <[email protected]>
Newsgroups gmane.comp.lang.lua.bind.user
Message-ID <1260014463.3339.12.camel@finwe>
I thought I was loosing for while, it but I think I managed to isolate a
bug...

print 'Hello from Lua!'

class 'test'

function test:__init()
    print 'Initialise class'
    print( self.a )
    print( self.b )
    print( self.c )
    print( self.d )

    self.a = 'One'
    self.b = 'Two'
    self.c = 'Three'
    self.d = 'Four'
end

t1 = test()
t2 = test()

print '2nd test.'

t1.a = 'Something different'
print( t2.a )

t1.b = 'Oh oh!'
print( t2.b )

print 'End'

Is that correct code in the init function?  I thought it was ok, but
it's 'linking' all but the first class member (a).

Here's what I get from running it.

Hello from Lua!
Initialise class
nil
nil
nil
nil
Initialise class
nil
Two
Three
Four
2nd test.
One
Oh oh!
End


Some thing screwy with the way the code for __newindex or __index works
perhaps? Or am I doing something dumb. 

Nigel


------------------------------------------------------------------------------
Join us December 9, 2009 for the Red Hat Virtual Experience,
a free event focused on virtualization and cloud computing. 
Attend in-depth sessions from your desk. Your couch. Anywhere.
http://p.sf.net/sfu/redhat-sfdev2dev
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.