lua-users home
lua-l archive

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


== true ...

I'll always cringe to that since beginners think an if _must_ have a comparison operator in it.

It is already boolean, no need to thest it again.

if process_the_data then
  slice_and_dice(data)
end

PS: Exception is when it explicitly checks it to be a boolean value at the same time, so 1 ought to be false..

Oh and this discussion is about removing not adding.

On Thu, Aug 2, 2018 at 2:53 PM, Peter Hickman <peterhickman386@googlemail.com> wrote:
The only things I would want to add to Lua is "trailing conditionals" (I think they are called)

if process_the_data == true then
  slice_and_dice(data)
end

would become

slice_and_dice(data) if process_the_data == true

It really reads smoother for me like this (and having 'unless' would make things readable too)

I don't use Lua as much as Ruby or Python but when I do I find the the Lua code can be quite verbose for trivial parts. I keep having to stop and ask "what is this bunch of syntax doing" The phrase 'intent revealing' comes to mind, Lua can be quite nuts and bolts and syntax can obscure semantics. When reading code what it is doing is more important that how it is doing it, at least on the first pass

However I use Lua for what it is. Never thought "if only ..."