lua-users home
lua-l archive

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


Hi:

On Wed, Aug 16, 2017 at 12:17 PM, Frank Kastenholz
<fkastenholz@verizon.net> wrote:
> The 2 primary rules for indentation that I use are
> 1 follow whatever the style is that already exists as
> 2 always indent the same way
> This reduces the amount of interpretation and thinking needed by the next person to read the code

Whish many times happens to be your older self.

> So I would always indent as:
>> if condition then
>>    call_my_routine()
>> else
>>    return
>> end
> And, as was suggested, I'd probably recast as
> if ~condition then
>     return
> end
> call_my_routine()

I've found that the second style is easy to reparse when there is more
code following, and teh indentation-saving is a nice to have, but when
it is alone, i.e.,

do -- or if, or for, or whatever block construct
  if condition then
    call_my_routine()
  else
    return
  end
end

This version is easier (for me) to read.

Francisco Olarte.