lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]

On 03/03/2017 08:26 PM, Dirk Laurie wrote:
> What is the main reason for using Luacheck?
> (a) A debugging tool.
> (b) Enforcing a certain style of coding.
> (c) Advising a programmer on things in his program that
> might make trouble one day.

All use cases I encountered in production work was (b).

This annoyed me as I think programmer should code any style he/she
wants. Code further may be arbitrarily post-processed according
corporation/company/another_person wishes. So I've implemented
code formatter (which currently strips all comments, so it is
still unsuitable for production use).

> Unless you use it for (b), I would not be concerned about the
> occasional extra warning in situations where any human can
> see it is OK.

Having a tool which can detect some (simple) cases of referencing
global variable is not bad. I appreciate luacheck for this ability.

> Turing has already taught us that we can't use
> a program to test correctness of a program. Why clutter
> Luacheck with exceptional cases?

Especially in dynamic languages as Lua. Where functions can
generate functions and arbitrary string can be converted to
function via load().

I believe only way to get result of program is execute it.
(And hope Turing believed/proved this too.)

> (c) Advising a programmer on things in his program that
> might make trouble one day.

You can add a hook to reference to global table but this have no
sense for code you trust (but useful for code stalking/research/hacking).

(Personally I prefer to prefix all queries to non-standard
global table values with "_G.".)

There are many implementations of idea to make language more
restrictive, from creating strict-type language, through code and
byte-code preanalysis, to sandboxes and run-time tracking.
Probably this is due new programmers which get from Lua more power
they can handle.

-- Martin