[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Question: Lua Constructor Mechanism
- From: nelson@...
- Date: Tue, 03 Jul 2001 07:11:20 -0000
Hi everyone,
Recently, I picked up some of the Lua related technical documents
again, and I tried to figure out how Lua can benefit my current
project. Regarding the article titled "SPE Paper" which is under the
link: http://www.tecgraf.puc-rio.br/lua/spe.html
I was trying to play with Lua's simple constuctor mechanism, by using
the example used in the document. Namely,
window1 = Window{ x = 200, y = 300, foreground = "blue" }
which is the syntactic sugar for
window1 = Window( { x = 200, y = 300, foreground = "blue" ) } with
initailization.
However, I received following error message:
----------------------------------------------------------------------
> window1 = Window{ x = 200, y=300, foreground = "blue" }
error: attempt to call global `Window' (a nil value)
stack traceback:
1: main of string "window1 = Window{ x = 200, y=300,foregroun..."
at line 1
----------------------------------------------------------------------
I expected it should create a instance of "Window" Class (I think in
C++. :) ) which internally creates table and the elements within. Of
course, I can explicitly create table as a window object.
But, I am trying to use Lua to simulate C++ syntax for prototyping
Therefore, I intend to try this interesting feature.
I wonder if there is anything need to be created / initailized before
constructing a object/instance using lua's constructor mechanism??
Thanks in advance!! :)
And enjoy using Lua!!
Nelson