lua-users home
lua-l archive

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



No, that wouldn't be valid Lua.

The closest I can think of is:

MYDEF { Variable1,
	TYPE = BYTE
}

That would call 'MYDEF' with a table, 'Variable1' being at [1]. Variable1 needs to be a table or userdata; you don't have reference types in Lua.

Using syntax rather close to Lua itself (your first sample) has the benefit that if your users want to explore the language more, their configuration files would actually resemble Lua code. Of course, you can always read in any syntax configuration, and programmatically apply the changes to your Lua state. I wouldn't. :)

-asko


Lythoner LY kirjoitti 19.10.2007 kello 14:02:

I define the configuration like the following format.

BYTE = 1

function MYDEF(variable)
    return variable
end

Variable1 = MYDEF
{
TYPE     = BYTE
}

Variable1 = MYDEF
{
TYPE     = BYTE
}

Variable1 = MYDEF
{
TYPE     = BYTE
}


Can I have the above configuration in this model?

MYDEF Variable1
{
    TYPE     = BYTE
}

MYDEF Variable2
{
    TYPE     = BYTE
}

MYDEF Variable3
{
    TYPE     = BYTE
}

Regards,

Krish