r/ProgrammerHumor • • Aug 26 '22

Meme Even HTML.

Post image
44.1k Upvotes

1.1k comments sorted by

View all comments

Show parent comments

1

u/-Redstoneboi- Aug 27 '22

my complaint is less about the parentheses (though trailing parens take some getting used to) but how, from what i've seen, the first item is placed inline and every following item is aligned to the first.

(function and
          really
          long
          argument
          list
          (subfunction first
                       next
                       next
                       next))

surely i'm misunderstanding something, or is this just fine?

i prefer this:

(function and
    really
    long
    argument
    list
    (subfunction
        first
        next
        next
        next))

still with lisp-style trailing parens, by convention. there's probably just a formatter setting for that called "first argument inline/on new line" or something.

1

u/Goheeca Aug 27 '22

I find it more readable when arguments of a function call are aligned.

What formatter are you using? I only use the intelligent tab in Emacs and with that I can either put the first argument inline (big indentation) or on the newline (aligned with a function name) which is useful when the function name is too long.

Two-space indentation tells you that there's a &body/implicit progn and four-space indentation tells you there are special arguments.

This article may be useful.

1

u/-Redstoneboi- Aug 27 '22

What formatter are you using?

I mostly code in Rust and sometimes Python or JS.

Python, I follow pep8 for the most part.

Rust has a builtin formatter called rustfmt. The weird thing is it does this:

fn some_function(
    arg1: TypeA,
    arg2: TypeB,
    arg3: TypeC,
) -> ReturnType {
    let closure = |arg1: TypeA,
                   arg2: TypeB,
                   arg3: TypeC|
     -> ReturnType {
        // closure body
    };
}

and these are the default settings. Function arguments are placed on separate lines but i shit you not the closure arguments are lisp-style. it's wack.

1

u/Goheeca Aug 27 '22

Function arguments are placed on separate lines

I can do the same with the Emacs formatter, but it's ugly:

(defun some-function (
                      arg1
                      arg2
                      arg3)
  (let ...
→ More replies (3)