[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: Lightweight syntax: a dissident view
- From: Drake Wilson <drake@...>
- Date: Sat, 27 Nov 2010 14:44:05 -0700
Quoth David Kastrup <dak@gnu.org>, on 2010-11-27 22:18:45 +0100:
> No, I couldn't. It is just an observation that Lua has a tendency not
> to make you choose. You don't pick between arrays and structures, for
> example.
That's because both can (abstractly) be treated as specific cases of
key-value mappings: a structure has a fixed set of symbolic keys, and
an array has a set of contiguous natural number keys starting from a
known point (for Lua, 1).
A function doesn't fit that notion very well, especially because these
aren't Haskellian "pure" functions but can also have side effects and
raise errors and so forth. The only borderline case is that a pure
function (that's also a function in the mathematical sense) could be
considered a potentially infinite, lazy key-value mapping, but I think
this is a very strained association when comparing the uses of tables
and functions in most programs; there aren't many nontrivial cases
where they can be reasonably transposed.
> On a less bizarre tangent, I expect threads and functions to become the
> same eventually.
That makes slightly more sense in that a function encapsulates a
computation with entry and exit points, and a coroutine ("thread" in
Lua) can be considered a special case of a closure where the entry and
exit points vary between calls. (This is stateful, but functions can
already close over and modify other private state, or public state.)
This already half-exists in the form of coroutine.wrap.
---> Drake Wilson
- References:
- Re: Lightweight syntax: a dissident view, Axel Kittenberger
- Re: Lightweight syntax: a dissident view, steve donovan
- Re: Lightweight syntax: a dissident view, phlnc8
- Re: Lightweight syntax: a dissident view, Doug Lua
- Re: Lightweight syntax: a dissident view, Dirk Laurie
- Re: Lightweight syntax: a dissident view, Luis Carvalho
- Re: Lightweight syntax: a dissident view, Mark Hamburg
- Re: Lightweight syntax: a dissident view, David Kastrup
- Re: Lightweight syntax: a dissident view, Drake Wilson
- Re: Lightweight syntax: a dissident view, David Kastrup