[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Documentation
- From: Philippe Lhoste <PhiLho@...>
- Date: Mon, 11 Dec 2000 06:24:29 -0500
I am trying to understand how to use properly the t:f() syntax, and how it is
useful, mostly looking at other people code. Unfortunately still scarse on the
while rereading the Lua 4.0 manua, I have meet a potential discrepancy:
In section 3, you say "The form t:f(x) is syntactic sugar for t.f(t,x), which
calls the method f from the table t passing the table itself as the first
parameter (see Section 4.5.9).".
In section 4.5.9, you say "The statement function v:f (...) ... end is just
syntactic sugar for v.f = function (self, ...) ... end
Note that the function gets an extra formal parameter called self."
Perhaps it is intended, but I find it a bit confusing...
It seems that t is available as global variable in f, anyway.
So I bet it is the section 4.5.9 which is correct.
Also the status of "self" and "arg" variables are a bit ambiguous. They are
not reserved words, nor internal variables (as defined in section 4.1) because
they have no underscore prefix, nor capital names. I suppose they are actually
What I am trying to explain is... Well, I am not sure. Perhaps you should
stress out the fact that they are special, eg. in the 4.1 section, where you
give some conventions.
Are _INPUT, _OUTPUT, _STDIN, _STDOUT, _STDERR, _PROMPT, _ERRORMESSAGE, _ALERT
the only internal variables, or are there others? Most of them are defined in
libraries, can we create our internal variables in our libraries, using the
same convention? Any risk of conflict?
Sorry for the dumb questions, I am still learning, and certainly on a par with
the gentlemen discuting coroutines or OO...
Philippe Lhoste (Paris -- France)
Professional programmer and amateur artist