rednifre
08/07/2024, 12:10 PM{}
, a line break can imply ;
, right? Could we get that between ()
, a line break can imply ,
? This feels like an oversight, especially with functional programming becomming more popular, where code tends to be more nested expressions, less sequential statements. The way it is, commas feel like the new semicolons.Sam
08/07/2024, 12:18 PMrednifre
08/07/2024, 12:19 PMSam
08/07/2024, 12:20 PMval a = (b +
c)
obviously shouldn't imply a comma, while this
val a = listOf(b
c)
couldrednifre
08/07/2024, 12:22 PMephemient
08/07/2024, 1:56 PM(
a
or
b
)
Stephan Schröder
08/07/2024, 1:56 PMrednifre
08/07/2024, 1:57 PMStephan Schröder
08/07/2024, 1:58 PMStephan Schröder
08/07/2024, 1:59 PMrednifre
08/07/2024, 1:59 PMStephan Schröder
08/07/2024, 2:00 PMephemient
08/07/2024, 2:00 PMephemient
08/07/2024, 2:00 PMrednifre
08/07/2024, 2:01 PM{
a;
b;
c
}
{
a;
b;
c;
}
{
a
b
c
}
Comma history:
(
a,
b,
c
)
(
a,
b,
c,
)
???
rednifre
08/07/2024, 2:02 PMStephan Schröder
08/07/2024, 2:02 PMStephan Schröder
08/07/2024, 2:03 PMephemient
08/07/2024, 2:05 PMephemient
08/07/2024, 2:06 PM{ a; b }
means { a; return b; }
in Rust, so it's not the same)Klitos Kyriacou
08/07/2024, 2:34 PMrednifre
08/07/2024, 2:35 PMHuib Donkers
08/07/2024, 2:36 PMfun f(a: Int, lambda: () -> Int = { 42 }): Int = 0
val x = f(1) // auto-insert semicolon? (Kotlin doesn't do this)
{ 2 }
val y = f(
f(1) // auto-insert comma?
{ 2 }
)
I'd like to know why it's a bad idea because it feels like a bad idea, but I can't figure out why.Miguel Santos
08/07/2024, 2:37 PMKlitos Kyriacou
08/07/2024, 2:38 PMHuib Donkers
08/07/2024, 2:47 PMprintln(
1 // shouldn't insert a comma here
shl 2
)
val x = 1
shl 2 // fails, semi colon inserted at line above
ephemient
08/07/2024, 2:58 PMval a = 1
val b = 0
val or = 2
val list = listOf(
a
or
b
) // [3] or [1, 0, 2]
Huib Donkers
08/07/2024, 3:09 PMval or = 0
val x =
1
or
2
// result: x == 1
ephemient
08/07/2024, 3:10 PMephemient
08/07/2024, 6:55 PMephemient
08/07/2024, 6:56 PMCLOVIS
08/08/2024, 8:18 AMval a = foo(
5
+2
)
Currently, foo(5+2)
, but this proposal would make it foo(5, +2)
.ephemient
08/08/2024, 3:39 PMfoo(
bar.let
{ it }
)