https://kotlinlang.org logo
Title
r

rednifre

08/11/2022, 1:12 PM
Are there any technical reasons why inside of (), line breaks can’t imply commas, similar how inside {}, line breaks imply semicolons?
v

Vampire

08/11/2022, 1:18 PM
Just guessing, but probably because it would be majorly confusing for most readers and a syntax interpretation nightmare.
r

rednifre

08/11/2022, 1:22 PM
But with programming style shifting from the imperative “a semicolon at the end of each line” to a more functional “either a dot at the start of the line, or a comma at the end”, I feel like Kotlin leaving out semicolons doesn’t get us as much as leaving out all those commas would. People got used to no longer seeing semicolons everywhere, so I’d assume they could also get used to skipping commas at the end of lines.
v

Vampire

08/11/2022, 1:27 PM
People could also get used to disallowing newline characters and having each class in only one single line. It would still be horrible for readability and most people would not want to adapt to it but just leave the language behind. And I said it is probably also a syntax interpretation nightmare.
But as I said, just guessing here. Feel free to open a feature request to the language committee for being able to leave out commas. 🙂
e

ephemient

08/11/2022, 2:51 PM
f(
  a,
  to,
  b
)
currently has a different meaning than
f(
  a
  to
  b
)
not necessarily insurmountable but it would be an incompatible change
r

rednifre

08/11/2022, 2:58 PM
@ephemient My IntelliJ complains about having that
to
on a single line like that, no matter whether it’s in {} or ().
e

ephemient

08/11/2022, 3:03 PM
I haven't opened the IDE but if that doesn't work then the KTIJ plugin is wrong
r

rednifre

08/11/2022, 3:07 PM
@ephemient Interesting, it autoformats it like this on paste:
fun main() {
        println(
            "hello"
                to
                "world"
        )
    }
… but manually changing it back to what you linked works, but it breaks the syntax highlighting.
So yeah, looks like it would be a breaking change then. Unless you check for infix operators I guess.