[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: function foo() in table
- From: Coroutines <coroutines@...>
- Date: Mon, 21 Apr 2014 14:21:19 -0700
On Mon, Apr 21, 2014 at 7:50 AM, Dirk Laurie <dirk.laurie@gmail.com> wrote:
> I have stopped using "local function f()" because I cannot remember
> whether it is the
> same as "local f = function()" or "local f; f=function()". So
> whichever of those I need,
> I code explicitly.
>
> Since I already take no sugar in my tea, why should I want it in my coffee?
I always remember that local function f() ... end is equivalent to
local f; f = function () ... end because when I have to write
recursive functions it errors when it tries to call the
not-yet-declared identifier from within itself.
I like writing f = function () ... end because when I indent the body
of the function the 'function' and 'end' line up on the same
indentation level -- similar to how in other languages you'd expect {
& } to line up. It feels more readable to me...
(just thought I'd comment because I prefer this one thing without
sugar, also :-)
f =
function (...)
do_something1()
do_something2()
end