Ray Eldath
01/26/2020, 7:01 PMlateinit
, only can be a var
instead of val
. and perhaps companion object
, it's a good idea, but i think the syntax is not very good.(though i think i can't come up with a better design 😶)streetsofboston
01/26/2020, 7:02 PMlateinit var
is somewhat like a val x by lazy
streetsofboston
01/26/2020, 7:03 PMcompanion object
, because it can implement interfaces and it can be used for smart constructors.Chills
01/26/2020, 7:04 PMstreetsofboston
01/26/2020, 7:05 PMwhen
expressionsChills
01/26/2020, 7:07 PMRay Eldath
01/26/2020, 7:09 PMwhen
+ deconstruction mostly enough for me.Chills
01/26/2020, 7:14 PMnfrankel
01/26/2020, 7:17 PMChills
01/26/2020, 7:22 PMstreetsofboston
01/26/2020, 7:22 PMAlowaniak
01/26/2020, 7:23 PMto
method to create a Pair
, really only makes sense in a Map
contextRay Eldath
01/26/2020, 7:25 PMstreetsofboston
01/26/2020, 7:26 PMChills
01/26/2020, 7:26 PMstreetsofboston
01/26/2020, 7:28 PMChills
01/26/2020, 7:28 PMnfrankel
01/26/2020, 7:29 PMRay Eldath
01/26/2020, 7:30 PMstreetsofboston
01/26/2020, 7:33 PMRay Eldath
01/26/2020, 7:36 PMto
problem......... today i met this hundred times, cause http4k
do uses to
a lot. and whenever the types mismatched, it will generate a pair, which will cover the origin of the problem, i think. kinda annoying.
but sometimes the to
is very useful. so double-edged sword here.gcx11
01/26/2020, 7:37 PMRay Eldath
01/26/2020, 7:38 PMstreetsofboston
01/26/2020, 7:38 PMsealed
part by the compiler?Ray Eldath
01/26/2020, 7:39 PMpermits
clause to specify. kotlin & scala can define multiple class in one file, so they just enforce the locality.
i don't like the constraint as well... though i understand the reason.gcx11
01/26/2020, 7:42 PMAlowaniak
01/26/2020, 8:15 PMto
, what annoys me even the most is that it creates a Pair
while IMO it's nonsensical to talk about pairs with "to", a pair doesn't have a directional relationship
It makes sense inside a Map
when it's an Entry
Kroppeb
01/26/2020, 11:07 PMto
function being bad. It is a nice short descriptive word that could be used for many things like DateTime::to(DateTime)
or Point::to(Point)
. But now we always risk in getting a pair if one of our inputs is nullable or just a completely different type, resulting in getting a type error in a different place which can be even more confusing to novices. If we still want to use to
for maps, we can make mapOf()
accept a lambda where there is an infix fun <http://K.to|K.to>(value : V)
available. The problem of coarse is that this would break backwards compatibility.
Unpacking of dataclasses has its flaws too. AFAIK all other languages who have something similar do not allow unpacking to the wrong amount of items. Although none of these languages have to work on the JVM.
Python does this check at runtime.
Haskell just uses the constructor notation to deconstruct as everything is immutable and "objects" are just containers for data without anything extra.
C sharp allows for function parameters to be used as output.
I would also love the nesting of destructuring. It doesn't happen often that this is useful, but it might be nice to have.Ray Eldath
01/27/2020, 4:16 AM