News for hackers. Stuff that matters.
Re:Delimiter-first code by pmontra on Friday December 09, 2022 @06:05AM (#33920035)
Or no delimiter at all in case there are no ambiguities to solve. Make a language that knows that different lines are for different stuff

  sections = [
    "one" 
    "two" 
    "three" 
  ] 
and separate with commas when you want to write something on the same line

  sections = [
    "one" 
    "two", "three" 
  ]
Re:Delimiter-first code by xcombelle on Friday December 09, 2022 @06:39AM (#33920221)

    sections: [
        "one"
        "two"
        "three"
    ]
and

    sections: [
        "one"
        ["two" "three"]
    ]
exists already and is named rebol (and their derivatives)
Re:Delimiter-first code by bstpierre on Friday December 09, 2022 @06:36AM (#33920211)
In your first example you’re just using newlines as delimiters, the second is allowing either newline or comma.
Re:Delimiter-first code by DougBTX on Friday December 09, 2022 @08:06AM (#33920787)
Or taking a Lisp perspective, atoms separated by white space.
Re:Delimiter-first code by Yahivin on Friday December 09, 2022 @11:26AM (#33923124)
That's how I do it in Civet (the CoffeeScript of TypeScript). It's a very small amount of complexity to add to the parser for a ton of convenience when using the language. https://github.com/DanielXMoore/Civet
Re:Delimiter-first code by allknowingfrog on Friday December 09, 2022 @11:51AM (#33923492)
Ruby has an interesting syntax for defining arrays of literal values.

  irb(main):001:0> sections = %w(one two three)
    => ["one", "two", "three"]
Re:Delimiter-first code by pmontra on Friday December 09, 2022 @01:01PM (#33924415)
I know and it works on multiple lines too. However I never use it. Requirements change, refactoring happens, one of those literals becomes an interpolated string and all of a sudden I have to rewrite all the array. Furthermore %w() is just not nice to look at IMHO.