I was reading lib/std/array_hash_map.zig and noticed some related functions are grouped with no empty line between them, e.g. removeByKey → removeByKeyGeneric around 1145-1146. And I also saw that same pattern everywhere outside array_hash_map.zig.
zig fmt keeps it that way, so seems intentional.
Curious what others think, do you use this style in your own code to show functions belong together, or do you always put a blank line between functions? Or am I missing something?
I always put a single line between functions. Otherwise I find it hard to discover the break in long functions I’m quickly skimming.
2 Likes
I really like to have this slight degree of freedom when writing struct methods to keep grouped small functions that have semantic similarity.
Perfect example is fromX / toX / asX helpers that are typically one or two lines and are often nicely laid out in group.
It’s in the spirit of zig fmt that allows gentle steering (like having multiple ways to break long lines) without sacrificing consistency too much. Typically function body is always on its own line and obviously more that one blank line between declarations is too much and would be atrocious taste 
But yeah, it technically allows to pack long functions which is a disgrace.
“A gentlemen is a man who can play the bagpipe but who doesn’t”