[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Lua and pointers
- From: "Alex Queiroz" <asandroq@...>
- Date: Mon, 20 Nov 2006 12:45:35 -0300
Hallo,
On 11/20/06, Theodor-Iulian Ciobanu <tciobanu@bitdefender.com> wrote:
Hello Lua,
Maybe the subject is not well chosen, as I'm thinking of the way C does it.
1) I have a variable whose contents I would like it to be modified by a function (would bee foo(&var) in C, with foo declared as foo(var_type*)). Can I do this in lua?
You can return more than one value from a Lua function. Or, add
the variable to a table and pass the table.
2) str[n] is not the n-th character of str (when str is of course a string). Would adding this to the language not be faster than string.sub(str,n,n) or would it stray the lua way? (or is there a better way of getting the n-th character from a string that I'm missed in the ref manual? I confess to still not owning a PiL :oops: )
string.at = function(str, n) return string.sub(str, n, n) end
print(("alex"):at(3)) => e
--
-alex
http://www.ventonegro.org/