lua-users home
lua-l archive

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


You are undoubtedly right. The terms I used weren't precisely and be sure I am worried about it. I am brazilian and I don't speak english freely. Sometimes, when I write in english, despite being a very nice language, I fell myself chained by words. Talking or writing, I didn't get the same freedom of expression. It's unbelievable because what I did is not exactly an english mistake, but mainly, a concept mistake. Despite this, I am sure the same mistake, in portuguese, would not be done. I don't know if I am able to avoid all the mistakes and become fully understood, however, I will sincerely try. Thank you for your answer.



----- Original Message ----- From: "Drake Wilson" <drake@begriffli.ch>
To: "Lua list" <lua@bazar2.conectiva.com.br>
Sent: Sunday, April 25, 2010 3:06 AM
Subject: Re: Calling a field in the same table


Quoth Luciano de Souza <luchyanus@predialnet.com.br>, on 2010-04-24 23:17:23 -0300:
database =
{
filename = 'test.db',
connection = sqlite3.open(database.filename)
}

An error shows up because I can't use "database.filename" inside the table "database".

The table isn't fully constructed yet.  If you have specific order of
evaluation requirements you can create the table first and then add
entries to it one-by-one:

database = {}
database.filename = 'test.db'
database.connection = sqlite3.open(database.filename)

I don't discuss if it's a good idea to call sqlite3.open as a field
of a table.  My doubt is: how to call another field of the same table
inside the table?

You're not calling sqlite3.open as a field of this table; you're
calling it and then using the result as a value in a table
constructor.  (You're accessing it as a field of the sqlite3 table,
but that's probably not what you meant.)  Nor are you calling another
field of the same table, nor calling a function retrieved from another
field in the table; you're using another field of the table as an
argument in your call to sqlite3.open.  Nor do you evaluate anything
"inside a table" per se when you are doing the above; you are
constructing the table, and evaluating various expressions to acquire
values with which to construct it.  The assignment of the table
reference to the 'database' variable doesn't occur until the
construction is complete.

Be careful with the precision of your terms; sapient creatures may be
able to infer what you mean through a large set of possible
distortions, but the computer is not so intelligent.

Luciano de Souza

---> Drake Wilson