lua-users home
lua-l archive

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


Actually, yeah there is something to initalize.. you need to create a
function named Window before you can do that. :) Remember, that syntax is
just a shorter way to call a function with a table as a parameter, so you
still need to define the function it's going to call.

Lua doesn't come "out of the box" with wrappers for windows and other such
things, you have to make them yourself, or check out the list of lua addons
at the lua webpage to find one that does what you want.

----- Original Message -----
From: <nelson@helikon.com>
To: "Multiple recipients of list" <lua-l@tecgraf.puc-rio.br>
Sent: Tuesday, July 03, 2001 12:11 AM
Subject: Question: Lua Constructor Mechanism


> 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
>
>
>
>