Lambda the Ultimate

inactiveTopic History of Lua
started 2/11/2004; 12:44:03 PM - last post 2/14/2004; 3:30:18 AM
andrew cooke - History of Lua  blueArrow
2/11/2004; 12:44:03 PM (reads: 10562, responses: 7)
History of Lua
A short paper that discusses how the language evolved (tensions between backwards compatability and improvements, as ever).

Although we've mentioned Lua before, I can't find mention of this paper.
Posted to history by andrew cooke on 2/11/04; 12:44:24 PM

Mitchell N Charity - Re: History of Lua  blueArrow
2/11/2004; 4:43:08 PM (reads: 405, responses: 3)
In the 2+ years since the history was written, Lua has moved on to Lua 5.0. Its main new features are "colaborative multithreading via Lua coroutines, full lexical scoping instead of upvalues, and metatables instead of tags and tag methods. Lua 5.0 also introduces booleans, proper tail calls, and weak tables. Other features are better support for packages, new API for loading Lua chunks, new error handling protocol, better error messages, and much more. Lua 5.0 is the first version to be released under the new license" [versions]. The main goal for the next version is said to be "incremental/generational garbage collection".

Here is the for statement. ;)

The Lua wiki has some interesting content, such as LuaAddons.

As of December, there is a Lua book out.

andrew cooke - Re: History of Lua  blueArrow
2/11/2004; 6:14:33 PM (reads: 396, responses: 2)
i've just been reading the language defintion and one thing that struck me as really ugly in lua is the way that multiple return values are handled. they're neither lists (which don't exist in lua) nor tables, but some strange second-class thing that changes size (discarding values or adding nulls!) as required.

it seems to me that the language could be made much cleaner by treating multiple return values as tables; parameter lists for functions as tables (which would give named params for free); and some syntax to flatten nested tables.

also, while it supports first class functions and closures, there's no way to structurally recurse over a table's contents - no car/cdr for tables. adding that seems like much more major surgery and perhaps you'd end up with scheme as a result ;o)

on the other hand, i suspect i could make lua behave in the way i describe above... and i wonder whether anyone has translated clos into lua. it strikes me as not being that difficult (but i'm no expert). i noticed support for optimized multiple inheritance in someone's add-on package, but not for multiple dispatch.

Sjoerd Visscher - Re: History of Lua  blueArrow
2/12/2004; 1:02:03 AM (reads: 355, responses: 1)
some syntax to flatten nested tables Why would you want that? Tables in Lua are very similar to Objects in Javascript. I've never ever needed to flatten objects, the whole idea seems very silly.

there's no way to structurally recurse over a table's contents There's for i in table, that's enough.

andrew cooke - Re: History of Lua  blueArrow
2/12/2004; 3:30:52 AM (reads: 346, responses: 0)
Why would you want that?

it was in the context of using tables for return values and parameter lists. if you wanted to call one function with argumnets that were the results of several othes, then it might be useful.

that's enough

i understand that all you really need are functions and the empty set.

(btw, when i said i thought i could implement what i suggested, i meant within lua, using the metatable stuff. my point was that it's sufficiently flexible that you can mould it to your needs.)

Timothy Downs - Re: History of Lua  blueArrow
2/13/2004; 9:03:03 PM (reads: 158, responses: 2)
Just a few comments in response to Andrew Cook:

I actually prefer the Lua way of doing multiple return values to just returning a table. It is less bulky to work with as it is.

Lua isn't Scheme. It is designed to make immediate sense to non-programmers, and to those who haven't come across the Scheme paradigm. It might not be a perfect, or even a "good" language, but is very suited for its niche- which from my perspective is that of a simple, small, fast, dynamic, and embeddable language.

There are plently of other good languages if you want what Lua is not.

andrew cooke - Re: History of Lua  blueArrow
2/14/2004; 3:13:55 AM (reads: 143, responses: 1)
It is designed to make immediate sense to non-programmers

these results don't make much sense to me:

> function zero_two ()
>> return 1,2
>> end
> zero_two()
> print (zero_two())
1       2
> print ((zero_two()))
1
> function one_one (x)
>> return 2 * x
>> end
> print (one_one(zero_two()))
2
> function two_two (x,y)
>> return 2*x, 3*y
>> end
> print (two_two(zero_two()))
2       6
> print (two_two((zero_two())))
stdin:2: attempt to perform arithmetic on local `y' (a nil value)
stack traceback:
        stdin:2: in function `two_two'
        stdin:1: in main chunk
        [C]: ?
> function three_three (x, y, z)
>> return 2*x, 3*y, 4*z
>> end
> print (three_three(zero_two()))
stdin:2: attempt to perform arithmetic on local `z' (a nil value)
stack traceback:
        stdin:2: in function `three_three'
        stdin:1: in main chunk
        [C]: ?
> print (three_three(0,zero_two()))
0       3       8
> print (three_three(zero_two(),0))
stdin:2: attempt to perform arithmetic on local `z' (a nil value)
stack traceback:
        stdin:2: in function `three_three'
        stdin:1: in main chunk
        [C]: ?

andrew cooke - Re: History of Lua  blueArrow
2/14/2004; 3:30:18 AM (reads: 140, responses: 0)
to clarify, there are two (perhaps three) uglies here.

the first is that an extra set of parentheses drops all but one return value.

the second is that multiple return values are treated as multiple only at the end of an argument list (see the last example). that stinks of implementation efficiency coming before regular semantics.

and the possible third (depending on your personal ethics, i guess) is that multiple values are dropped silently and extra nulls inserted silently.

i do agree that being able to treat tables as lists is taking things too far towards scheme - i hinted at that in my own post - but i don't think there's anything particularly un-natural about recursion to non-programmers.

ps:

> function zero_what ()
>> return {1,2}
>> end
> print (two_two(zero_what()))
stdin:2: attempt to perform arithmetic on local `x' (a table value)
stack traceback:
        stdin:2: in function `two_two'
        stdin:1: in main chunk
[C]: ?

would that really be more complicated if it worked?