lua-users home
lua-l archive

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


  I just noticed in the Lua Wiki that there is a patch to allow function
definitions of this type within a table.  An excerpt from
http://lua-users.org/wiki/LuaPowerPatches :

Enhanced table constructors
The record part of table constructors (field=value) is modified so that
function statements are allowed and the comma is optional now. So this
becomes valid:

x = {
  function foo() end
  function bar() end
  c=1
  d=2
}

and is the same as:

x = {
  foo=function() end,
  bar=function() end,
  c=1,
  d=2,
}

  Dan East

-----Original Message-----
From: lua-bounces@bazar2.conectiva.com.br
[mailto:lua-bounces@bazar2.conectiva.com.br]On Behalf Of Dan East
Sent: Friday, June 11, 2004 12:48 PM
To: Lua list
Subject: Multiple Questions


  Hi.  I have a few small questions.

1) Why is only one function declaration syntax supported in tables?  This
works:

MyClass = {
  MyFunc = function() end;
}

This does not:

MyClass = {
  function MyFunc() end;
}

2) In C it possible to determine the number of elements in a table without
iterating it.

3) My C function is called from LUA and passed a table.  How can I find the
name of the table?  lua_tostring returns nil.  In LUA I have
"library.RegisterClass(MyClass)", in C I need the string "MyClass".

4) I could not find any forums discussing the API side of LUA (all were pure
scripting discussion).  If there is a better place to pose rudimentary
questions of the sort I've been asking then please let me know.  You guys
seem to be discussing some pretty hard core stuff and I hate to waste your
time.

  Thanks!

  Dan East