[Date Prev][Date Next][Thread Prev][Thread Next]
- Subject: Re: Lambdas
- From: Philippe Verdy <verdy_p@...>
- Date: Mon, 19 Nov 2018 14:31:01 +0100
Wow. This has changed! I should have read the new 5.3 manual.
And I have an old Lua implementation that does not behave like this (it did not allow "function a.b:c() end", only "function c() end" and there was no need of the leading "local", this was still only allowed as a statement like in Lua 5.3).
So OK there's now a difference in the Lua 5.3 manual, but this requires now the syntax "local function c() ... end" which really creates now a local variable in all cases (requires a separate "local" statement, which cannot be used as part of an _expression_, except in the body of another declared function)
Sorry for the confusion. Lua is still a young language and many things have not always been specified precisely and formally... We should always specify the Lua version when speaking... And frequently the Lua implementation as well: each version/implementation is a separate dialect, a distinct language with its specificities (this creates known portability problems, and maintenance problems if one "upgrades" its Lua installation to a new version...). When Lua changes these things, it should create a major version, and use minor versions only for security fixes or performance improvements.
> I'm sure that:
> c=1; do function c() end; end print(c)
> --> 1
This code never prints 1, it always prints "function: 0xnnnn".