Ruckus
05/11/2018, 7:22 PM{
to the same line as the let
raulraja
05/14/2018, 8:04 PMas
is missleading since it's already associated with casting. I think what you have here is an explicit type ascription and :
would be more appropiate since that is already used for type ascription in functions, local variables etc.
It's also how it's represented in other languages:
https://stackoverflow.com/questions/36389974/what-is-type-ascription
https://stackoverflow.com/questions/2087250/what-is-the-purpose-of-type-ascriptions-in-scala
takesAmbiguousType([1, 2, 3] : Set<Int>) // OK
takesAmbiguousType([1, 2, 3] : Array<Int>) // OK
ilya.gorbunov
05/14/2018, 8:38 PMorangy
05/14/2018, 9:10 PMConfiguration(val host: String, val port: Int, val filters: List<Filter>)
and I want to build a Map<String, List<Configuration>>
. How would it look like?Aregev2
05/15/2018, 5:06 PMbenleggiero
05/15/2018, 10:17 PMkarelpeeters
05/16/2018, 8:27 AMtschuchort
05/16/2018, 10:36 AMbbade_
05/17/2018, 10:02 PMprivate val _events: ReplaySubject<Thing>
val events: Observable<Thing>
get = _events
Has there been any consideration about adding syntax like this as a shorthand?
private val events: ReplaySubject<Thing>
public get(): Observable
elect
05/18/2018, 7:40 AMreturn
in init
amorenew
05/21/2018, 6:33 AMbenleggiero
05/22/2018, 1:08 AM@
annotation that says “Yes, I know this will make things weird for other JVM languages but I really want this”. Hopefully it’s possible without name mangling, though.
The reason I propose this feature is because it would be essential for the Collection Literals KEEP as it’s currently written. https://github.com/Kotlin/KEEP/pull/112#issuecomment-390830008wcaokaze
05/24/2018, 3:26 PMefemoney
05/25/2018, 8:58 AM@Named("coins") Safe coinSafe;
@Named("jewelry") Safe jewelrySafe;
In a large codebase people might forget to add the right annotation or in the case of Named
, the correct value.
Being able to create a typealias
like below would be really helpful.
typealias CoinSafe = @Named("coins") Safe
typealias JewelrySafe = @Named("jewelry") Safe
// and usage becomes
CoinSafe coinSafe;
JewelrySafe jewelrySafe;
I’m also quite skeptical though, because typealias
(right now) implies interchangeability and for special cases/mistakes with this feature, interchanging types might introduce bugs.Pere Casafont
05/25/2018, 11:21 AMimplement
keyword to be used instead of override
when what you're "overriding" are actually interface or abstract methods?paulblessing
05/31/2018, 4:04 PMPerson(
name = run {
// some complicated things
"Nathan"
},
age = run {
// some complicated things
17
}
)
Zac Sweers
05/31/2018, 6:49 PMdata class Foo(val bar: String, val baz: String = "baz")
// somewhere later
val bazValue = getBazValue() ?: Unset
Foo(
bar = "bar",
baz = bazValue
)
Unset
(name could be something better) could be a marker to indicate that you want to defer to the default value. Similar to Unset
. Then you could denote that a value is undefined and basically pretend the argument was never setwaqas
06/11/2018, 2:26 PMdiesieben07
06/11/2018, 2:28 PM"Hello $name"
to compile to something like a StringTemplate
object (if needed, it should also still be assignable to String
obviously).
More hand-wavy API:
interface StringTemplate {
val placeholders: List<String>
fun getValue(placeholder: String): Any?
fun toString(mapper: (@ParameterName("name") String, @ParameterName("value") Any?) -> Any?): String
}
nwh
06/18/2018, 1:52 AMinterface Flippable<T> {
fun flip(): T
}
extend String as Flippable<String> {
// Implements all of the Flippable properties/methods missing from the base class
fun flip(): String {
...
}
}
Then you could treat a String
as an instance of Flippable
Zac Sweers
06/19/2018, 7:32 AMif (title == null) title = tmdbEpisode.name
I wish I could do title ?= thing
. Like Ruby’s ||=
where it assigns only if not assigned yet. That could possibly mesh nicely with what I was raising here too: https://kotlinlang.slack.com/archives/C0B9K7EP2/p1527792590000151nwh
06/19/2018, 10:42 PMcatch
could receive errors as a parameter, like this:
try { ... } catch { it.printStackTrace() }
I assume this would be a breaking change, but just allowing it to receive a parameter wouldn't be (no implied it
):
try { ... } catch { err -> ... }
If both of these are breaking changes, maybe the syntax could be changed to handle
instead of catch
, and the try statement would have to have one or the other. The current syntax of catch
drives me nuts.littlelightcz
07/04/2018, 5:19 PMdodalovic
07/09/2018, 3:55 PMtopLevelFun() = Unit
class Foo {
bar() {
//
}
baz() = println("baz")
}
dodalovic
07/09/2018, 4:33 PMilya.gorbunov
07/13/2018, 8:08 PMAregev2
07/13/2018, 8:34 PMbenleggiero
07/15/2018, 9:03 PMInt64Size
vs `Int8Size`:
https://github.com/BlueHuskyStudios/Blue-Base/commit/5baf26fb495b29bd9ad4a7b1099d76c9f0c1c163
Just about all the code between these classes is identical, but solely because I can only say either “Use a `Long`” or “Use any implementation of `Number`“, I have to slowly go through every native number type and make separate implementations for these.
If I could just specify “This is a Size
implementation based on a native integer”, I could write it once and let generics fill in the blanks.
Swift did this with a set of 9 interfaces, and it makes it super easy to let the compiler reason about what I’m getting at:
https://developer.apple.com/documentation/swift/swift_standard_library/numbers_and_basic_values/numeric_protocols
https://github.com/apple/swift-evolution/blob/master/proposals/0104-improved-integers.mdDominaezzz
07/16/2018, 11:09 AMAutoCloseable
, which I think should be the JVM implementation of it.dsavvinov
07/16/2018, 3:28 PMdsavvinov
07/16/2018, 3:28 PMjdemeulenaere
07/16/2018, 7:54 PMvoddan
07/17/2018, 12:28 PM