kirillrakhman
01/29/2018, 12:29 PMAndreas Sinz
01/29/2018, 12:46 PMkirillrakhman
01/29/2018, 1:06 PMuhe
01/29/2018, 1:20 PMspand
01/29/2018, 1:28 PMuhe
01/29/2018, 1:37 PMpoohbar
01/29/2018, 1:45 PMpoohbar
01/29/2018, 1:46 PMspand
01/29/2018, 1:48 PMpoohbar
01/29/2018, 1:48 PMAndreas Sinz
01/29/2018, 2:05 PMrrader
01/29/2018, 2:24 PMpoohbar
01/29/2018, 2:24 PMtypealias PhoneNumber = String
?rrader
01/29/2018, 2:27 PMrrader
01/29/2018, 2:35 PMAndreas Sinz
01/29/2018, 2:51 PMrrader
01/29/2018, 3:07 PMAndreas Sinz
01/29/2018, 3:17 PMA
is the Phantom Type, FileHandle
is a wrapper. inline classes make it possible to make existing types more "type-safe" without a wrapper classrrader
01/29/2018, 3:22 PMAndreas Sinz
01/29/2018, 3:22 PMrrader
01/29/2018, 3:22 PMr4zzz4k
01/29/2018, 3:26 PMtypealias
doesn't create new type, so for example you can't properly redefine methods on it. The following code:
typealias MyInt = Int
operator fun MyInt.plus(o: Int): MyInt = this - o
yields the following warning:
Extension is shadowed by a member: public final operator fun plus(other: Int): Int
(and of course mentioned operator is used instead of my own function).poohbar
01/29/2018, 3:29 PMAndreas Sinz
01/29/2018, 3:33 PMinline class UserId(private val id: Int) {
operator fun equals(other: UserId) = id == other.id
}
val userId = UserId(5) //At runtime its just an Int, but it's different inside the code
userId == UserId(1) //Works
userId == 5 //Does not work, because there is no "operator equals(Int)" defined
benleggiero
01/29/2018, 6:05 PMAndreas Sinz
01/29/2018, 6:28 PMbenleggiero
01/29/2018, 6:30 PMinline class Foo(x: Long)
// later ...
class Bar {
fun fooBar(): Foo = Foo(7)
}
What does new Bar().fooBar()
look like in Java?r4zzz4k
01/29/2018, 6:33 PMlong fooBar()
. At least for me the idea of inline class
sounds exactly like that. I didn't look through commits though, so I might be entirely wrong.Andreas Sinz
01/29/2018, 6:36 PMfooBar(): Long
in javaAndreas Sinz
01/29/2018, 6:37 PMinline class
should work from javabenleggiero
01/29/2018, 6:40 PMLong
, not long
in Java?Andreas Sinz
01/29/2018, 6:42 PMr4zzz4k
01/29/2018, 6:45 PMr4zzz4k
01/29/2018, 6:46 PMjava.lang.Long
for kotlin.Long?
eddie
01/29/2018, 9:42 PMinline class
and not a parallel for typealias
such as typedef
, especially if it's restricted to a single field? Then you could introduce syntax for grouping extension properties/functions under a given receiver type instead (which is a feature that's been requested separately in the past).eddie
01/29/2018, 9:46 PMdata class
, no? The optimizations performed by the compiler/runtime should be transparent.dmitry.petrov
01/29/2018, 10:07 PMdata class
(for the reasons of backward compatibility, at least; no, data classes never were anything like that)dmitry.petrov
01/29/2018, 10:11 PMnewtype
, because these things are not meant to be in subtyping relation with corresponding single field type.dmitry.petrov
01/29/2018, 10:14 PMdmitry.petrov
01/29/2018, 10:15 PMeddie
01/29/2018, 10:32 PMNo, it can't be done with aA JIT or an otherwise optimizing compiler (i.e. LLVM) can't inline the sole value of a data class when possible? If the constraint is the JVM, this should be another(for the reasons of backward compatibility, at least; no, data classes never were anything like that)data class
@Jvm*
annotation instead of part of the language, IMO.gildor
01/30/2018, 12:16 AMdmitry.petrov
01/30/2018, 5:40 AMrrader
01/30/2018, 7:33 AMclass UserId
isn't it a wrapper class of Int ?Andreas Sinz
01/30/2018, 8:30 AMinline function
louiscad
01/31/2018, 9:09 AM