[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Propsoal: a lua dialect without nil
- From: steve donovan <steve.j.donovan@...>
- Date: Tue, 15 Feb 2011 14:40:28 +0200
On Tue, Feb 15, 2011 at 2:27 PM, Matthew Frazier
<leafstormrush@gmail.com> wrote:
> "does it equal nil." I'm borrowing from Python here, but "in" and "del"
> keywords for testing whether a key is actually *defined* in a table (i.e. "3
> in t") and deleting keys from a table (i.e. "del t[3]") might be useful for
> this.
Nah, more operators - we have enough.
It is interesting to see how Go solved the problem, in a rather
Lua-ish way: return two values, with the second indicating whether we
actually found something, and are not just getting the default value.
Ruby has a way of making hashes [1] that specify the default value if
the key is not found.
And naturally it's not difficult to do this in Lua, but then we have
to break the habit of using raw tables for everything.
steve d.
[1] honest, it was not intended as a joke..I think.