lua-users home
lua-l archive

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


* Patrick:

> C is perfect in several ways, it can run on "bare metal", it's small
> and fast but I can't transfer several useful concepts from Lua back to
> C. Simple code like this seems problematic to me in C:
> SomeTable= {Lua = "fun", a = 1, b = 2, c = 1 + 2}

The following is a valid SML program:

val SomeTable= {Lua = "fun", a = 1, b = 2, c = 1 + 2}

SML is a statically typed language, and SomeTable is typed like this:

   {a: int, b: int, c: int, Lua: string}

This works because SML has type inference and structural record types
(C structs are mostly nominal).

In case you wonder, it's a coincidence that your Lua example is almost
SML, too.  There's little overlap, and I think it's not too harsh to
call SML's grammar (or lack thereof) an embarrassment.  I guess it's
the only language where the designers put much more effort into
semantics than syntax, and it shows.