Nir
07/05/2019, 2:34 PMstreetsofboston
07/05/2019, 2:37 PMopen
.Nir
07/05/2019, 2:39 PMUser
and a MutableUser
that inherits from User?x = x.copy(age=5)
is just really verbose compared to x.age=5
.gildor
07/05/2019, 3:10 PMstreetsofboston
07/05/2019, 3:14 PMNir
07/05/2019, 3:18 PMx = x.copy(age=5)
is still very verboseList
, and you can call them with your MutableList, which is fantastic.streetsofboston
07/05/2019, 3:20 PMdata class
implements. However, the copy
function won’t be derivable from that interface….Nir
07/05/2019, 3:20 PMconst
as a modifier, which is really fantastic.streetsofboston
07/05/2019, 3:21 PMconst
. I like that, too. I wish, though, that const
were the default and another keyword like mutable
would have been used instead.Nir
07/05/2019, 3:21 PMvoid foo(const string&)
is guaranteed (well, almost) not to modify its inputstring
List
and MutableList
essentially emulates this with inheritance.streetsofboston
07/05/2019, 3:24 PMMutableList
being a sub-interface of List
. ImmutableList
and MutableList
should not have a parent-child hierarchy. If I have a List
, it could be implemented by a mutable list, which means I cannot assume the List
i have is actual immutable..Nir
07/05/2019, 3:29 PMList
is immutable (IMHO)const&
is actually immutable.immutable
keyword but it's been a pretty mixed bag by most accountsstreetsofboston
07/05/2019, 3:31 PMNir
07/05/2019, 3:33 PMstreetsofboston
07/05/2019, 3:50 PMinterface MyData {
val id: Int
val name: String
}
data class MutableMyData(
override var id: Int,
override var name: String
): MyData
Won’t get rid of the verbosity you try to avoid, though.Nir
07/05/2019, 4:00 PMstreetsofboston
07/05/2019, 4:03 PMcopy
function is the biggest trip-up. I wish there was a data interface
of some sortNir
07/05/2019, 4:03 PM