lua-users home
lua-l archive

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



On Mar 10, 2005, at 19:52, Ben Sunshine-Hill wrote:

On Thu, 10 Mar 2005 19:45:46 +0100, PA <petite.abeille@gmail.com> wrote:

Ooops... my bad... so... { foo = "bar" } is correct, right?

But I need square brackets if I want something like "foo bar" = "baz",
for example { [ "foo bar" ] = "baz" }, correct?

Yes, and I think so. Though when you think about it, I don't think
that allowing spaces would introduce parsing ambiguities.... hm.

Hmmm... what would it take to allow the left end side to be a quoted string? For what is supposedly a data description language, the square bracket notation adds quite some noise in my opinion.

For example, I have a simple table to describe file extensions and their matching MIME type, something like this:

{
	[ "669" ] = "audio/x-mod",

	[ "a" ] = "application/x-archive",
	[ "ag" ] = "application/x-applixgraphics",
	[ "aiff" ] = "audio/x-aiff"
}

And another table to describe HTTP status codes:

{
        [ "100" ] = "Continue",
        [ "101" ] = "Switching Protocols",

        [ "200" ] = "OK"
}

Removing the square brackets and quotes doesn't cute it though as Lua seems to not look kindly at a key being a number (?!?!?)...

Ideally, I would like to write the above trivial tables without the need to clutter them with square brackets. Is there a simple way to achieve that?

Cheers

--
PA, Onnay Equitursay
http://alt.textdrive.com/