lua-users home
lua-l archive

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




On Sat, Jan 4, 2014 at 5:04 PM, Tim Hill <drtimhill@gmail.com> wrote:

On Jan 4, 2014, at 3:52 PM, immerrr again <immerrr+lua@gmail.com> wrote:

> Hi all
>
> Emacs mode for Lua [1] has been proposing 3-space indentation as
> default for its new users for ages, but at some point I've started
> receiving rather regular requests (here's a public example: [2]) to
> change this to 2 (according to "canonical" style used in Lua-related
> books [2]) or at least 4 (to match other languages' conventions).
>
> So, it'd be nice to collect some opinions/statistics about indentation
> offsets that are currently used community-wide. Admittedly, I haven't
> programmed in Lua for quite a while.
>
> Aside from that, does anyone remember the origin of this 3-space
> indentation convention? I tried to trace it recently but the only
> relevant responses I found were smth like "three spaces is Lua code
> style, don't ask why".
>
> Cheers,
> immerrr
>
> 1. https://github.com/immerrr/lua-mode/
> 2. https://github.com/immerrr/lua-mode/issues/56
> 3. http://lua-users.org/wiki/LuaStyleGuide
>

We standardize on 4 for indents here to match across all languages and platforms .. makes code more consistent to read. I’ve always felt 4 is a good “Goldilocks” width, not too wide (stops code creep across page) and not too narrow (too hard for eye to follow).

I think 3 came from the “tabs stops at prime number intervals” camp? :)

—Tim



I wouldn't say 'across all languages and platforms' because some languages don't follow this and you're roundly chided for not conforming.

I personally prefer 2 spaces, not tabs. But mostly because I'm narcissistic and live vicariously through my code and prefer it to look the way I wrote it.

~Johnneylee