• alyth@lemmy.world
    link
    fedilink
    arrow-up
    6
    ·
    9 months ago

    What is Lisp style, Lisp doesn’t have this syntax? Or is it referring to something other than Lisp languages. Same with Haskell.

    • stackPeek@lemmy.worldOP
      link
      fedilink
      arrow-up
      3
      ·
      9 months ago

      Haven’t coded with Lisp, but I’ve seen Lisp codes that are formatted like that. Haskell too.

  • vampire@lemmy.world
    link
    fedilink
    arrow-up
    7
    arrow-down
    2
    ·
    9 months ago

    Just run with the default style of the de-facto formatter for whatever language you are using. It’s really not worth any mental effort.

    • GissaMittJobb
      link
      fedilink
      arrow-up
      5
      ·
      9 months ago

      This is true, but it also moves the discussion to which is the superior code for matter for languages that don’t have a clear default option, and of course to which languages have the best formatters.

      I have a hard stance in this question - code formatters should be deterministic on any given syntax tree - there should be no leeway for choosing how any given piece of code formats. Seriously. If your anti-bikeshedding tool does not completely eliminate the bikeshedding, you have not done your job correctly.

  • janAkali@lemmy.one
    link
    fedilink
    English
    arrow-up
    5
    ·
    edit-2
    9 months ago

    Ew. I usually don’t use curly braced languages. But whenever I need to define collections on multiple lines I always put opening bracket on the end of the line and closing bracket on the same indent level as the start of the statement:

    let hello = [
      "Hello, there!",
    ]
    var
      a = true
      arr = [
        "line 1",
        "line 2",
      ]
    
  • Cerise_W@lemmy.world
    link
    fedilink
    arrow-up
    2
    ·
    9 months ago

    Can we talk about variable scope? Is x changing inside a called function without so much as a pointer being passed?

    • Deuces@lemmy.world
      link
      fedilink
      arrow-up
      5
      ·
      9 months ago

      Avoiding global variables is just something dumb people do to protect themselves. Real programmers declare every variable before Main.