Marc Knaup
01/12/2021, 1:23 PMOleg Yukhnevich
01/12/2021, 1:31 PMOleg Yukhnevich
01/12/2021, 1:32 PMMarc Knaup
01/12/2021, 1:36 PMHanno
01/12/2021, 5:56 PMMarc Knaup
01/12/2021, 6:00 PMHanno
01/12/2021, 7:32 PMMarc Knaup
01/12/2021, 7:35 PMHanno
01/12/2021, 7:49 PMMarc Knaup
01/12/2021, 7:51 PMset is suitable here as that’s meant to be used with […]. I’d call it assign just like suggested in the PR comment above.Ben Woodworth
01/12/2021, 9:49 PM=. How about instead of assignment overloading, adding an association operator that uses : instead of =?Marc Knaup
01/12/2021, 10:54 PM: denotes a type of something 🤔louiscad
01/13/2021, 9:13 AM1 = 3louiscad
01/13/2021, 9:14 AMMarc Knaup
01/13/2021, 9:18 AM== in Kotlin 🤔louiscad
01/13/2021, 9:20 AM"yes" = "no" or "1" = "3"louiscad
01/13/2021, 9:21 AM"yes" just became "no"? one could wonder.louiscad
01/13/2021, 9:22 AMlouiscad
01/13/2021, 9:22 AMString, some would ask for it to work on Number as well blob upside downMarc Knaup
01/13/2021, 9:28 AMlouiscad
01/13/2021, 9:32 AMtrue and false mean in a context. Would sure be handy for a politics DSL!
I'd prefer the assignment operator to stick to its meaning regardless of the context. Maybe another (new?) operator like <- or other could be used instead.Marc Knaup
01/13/2021, 9:33 AMthis["yes"] = "no"Marc Knaup
01/13/2021, 9:34 AMlouiscad
01/13/2021, 9:35 AMthis, but also the get operator ([ ]), and past that point, the semantic meaning is entirely different.Marc Knaup
01/13/2021, 9:41 AM["yes"] = "no" looks like a destructuring 😅
There's probably no way to solve that with existing syntax.elizarov
01/13/2021, 5:08 PMMarc Knaup
01/13/2021, 5:10 PM:=, =>, <-, ~=
But I’m not sure if such a feature is worth additional syntax until we find more common use cases.louiscad
01/13/2021, 5:13 PM:= is the less confusing option of what's on the table so far.
=> might be confused with JS lambdas, ~= is vague I'd say, <- might seem to go in the wrong direction (and so could it the other way around).Marc Knaup
01/13/2021, 5:14 PM= would allow implementing type coercion. And delegates are a special kind of assignment already.Marc Knaup
01/13/2021, 5:15 PM<- the wrong direction?
RHS is assigned to LHS, so right to left.Marc Knaup
01/13/2021, 5:15 PMlouiscad
01/13/2021, 5:16 PM: when it's after an expression (and keep its current meaning when it's after a declaration)louiscad
01/13/2021, 5:17 PM=>, which is the opposite direction of <-. Both make sense in some contexts, but Kotlin is a general purpose programming language.Marc Knaup
01/13/2021, 5:19 PM: can quickly lead to confusion.
I personally wouldn’t consider PHP a good example for anything - except as a counter-example 😅Marc Knaup
01/13/2021, 5:20 PM=> is too close to functions anyway.Marc Knaup
01/13/2021, 5:20 PMvar, val and let between Kotlin, JS and Swift because they’re too similar yet the meaning changes.louiscad
01/13/2021, 5:20 PMMarc Knaup
01/13/2021, 5:21 PM<< and >> since they’re not used for bit shifting.Marc Knaup
01/13/2021, 5:24 PMMarc Knaup
01/13/2021, 5:25 PMMarc Knaup
01/13/2021, 5:27 PM$"bar" = "foo"
@"bar" = "foo"
#"bar" = "foo"
:"bar" = "foo"
&"bar" = "foo"
~"bar" = "foo"
Or without quotes if LHS should reference the value of a variable bar instead of a String.louiscad
01/13/2021, 5:28 PMlouiscad
01/13/2021, 5:28 PM: that does what you asked for in the first place? assign?Marc Knaup
01/13/2021, 5:29 PM[foo]: barMarc Knaup
01/13/2021, 5:29 PMassign is =, isn’t it?Marc Knaup
01/13/2021, 5:29 PMMarc Knaup
01/13/2021, 5:30 PMthis[a] = b you could also re-use operator fun set.louiscad
01/13/2021, 5:33 PMoperator fun set makes the most sense, yep, though it might get confusing to have one name for two syntax using a different symbol 🤔Marc Knaup
01/13/2021, 5:40 PMlouiscad
01/13/2021, 5:49 PMMarc Knaup
01/13/2021, 6:39 PMthis["a"] = "b"
"a" := "b" // or whatever syntax
So it should be totally fine to have the same operator function name.edrd
07/10/2022, 12:18 AM