jtravis
09/19/2018, 7:50 PMartem_zin
09/24/2018, 4:34 AMResult
(also known as SuccessOrError
) type before 1.3 release?
I think it can be improved and you might want it to be improved for the future of language, I’m writing a KEEP but it takes a long time so I wanted to reach out so you know it’s comingholgerbrandl
09/24/2018, 8:08 AMFleshgrinder
09/24/2018, 5:33 PMadam-mcneilly
09/25/2018, 6:18 PMwhen
statement support multiple conditions for the else block, does anyone know if there's an official feature request or discussion around this?
when (x) {
1, 2 -> println ("one or two")
3, else -> printlnt("doesn't compile")
}
voddan
09/26/2018, 5:00 AMLeoColman
09/27/2018, 6:52 PMInt.length
, that counts how many numbers are in an Integer?jkbbwr
10/05/2018, 11:50 PMdata class
is that basically designed as a compiler plugin? if so would there be a way to extend this in the future to add user defined (with compiler plugin)Marc Knaup
10/08/2018, 2:32 PMclass Something<Context = DefaultContext>
-> val something: Something
natpryce
10/10/2018, 7:50 AMobject foo {
operator fun invoke() {
println("an object")
}
}
fun foo() {
println("a function")
}
fun main(args: Array<String>) {
foo() // prints "a function"
}
Ruckus
10/12/2018, 5:19 PMmain
can be suspended in 1.3, I propose an all-suspend plugin that would make all functions suspend
functions (along the same lines of the all-open plugin), allowing a Go style of programming without having to mark each function as suspended.
(Note: I know next to nothing about Go, so I could be way off in my comparison. I'm also not sure of the implications of this idea, so I haven't even decided if I like it myself, but I figured I'd throw it out there.)cbruegg
10/12/2018, 5:25 PMelect
10/15/2018, 4:17 PMelect
10/24/2018, 8:18 AMVladyslav Sitalo
10/24/2018, 1:35 PMdynamic
type available only on the js platform? From what I’m reading for now it seems to be that it was not supposed to be like that initially (i.e. here: https://discuss.kotlinlang.org/t/dynamic-type/1145)louiscad
10/25/2018, 10:17 AMdynamic
behavior during prototyping/development: allow unresolved symbols after TODO(…)
calls.
I created an issue: https://youtrack.jetbrains.com/issue/KT-27818addamsson
10/26/2018, 11:56 AMnatpryce
10/30/2018, 8:34 AMelect
10/30/2018, 1:01 PM-
to _
in order to allow calling function with inline classes from java? https://kotlinlang.org/docs/reference/inline-classes.html#manglingkarelpeeters
10/30/2018, 1:25 PMkarelpeeters
11/02/2018, 10:25 AMfor (i in 0 until 10 step 2) {
println(i)
}
This code is only partially optimized, there is still an allocation of both an IntRange
and an IntProgression
. This get worse when this loop is part of another loop, that means two useless allocations per iteration of the outer loop. Are there plans to optimize all of that away?Dominaezzz
11/02/2018, 11:44 AMmacro
and like inline functions, will support "reified" generics and cannot be called outside of Kotlin (i.e Java), but instead of being inlined at the call site, they are generated and called. (Like templates in C++). Any reflection done in the function is inlined. This allows for IDE friendly templates(C++), easy code generation and maybe something similar to LINQ to SQL.Dico
11/02/2018, 4:10 PMlouiscad
11/03/2018, 1:17 AMlazy { … }
)addamsson
11/06/2018, 3:33 PMaarjav
11/12/2018, 9:38 PMsksk
11/13/2018, 11:09 AMdata class CPosition(var x: Int, var y: Int)
fun main(args: Array<String>)
{
addComponent<CPosition>().apply {
x = 5
y = 5
}
}
fun <T : new> addComponent(): T
{
// create an instance of T
val c = T()
// do stuff with c
return c
}
pablisco
11/20/2018, 11:48 AMval items = mutableListOf<Item>()
get() : List<Items>
zak.taccardi
11/24/2018, 8:40 PMtypealias
as a namespace?
typealias MainViewModel = ViewModel<State>
Then I’d like to have classes defined as:
MainViewModel.State
marcusfs
11/28/2018, 3:10 PMsealed data class Foo {
First,
Second(val x: Int),
Third(val s: String)
}
instead of this:
sealed class Foo {
object First : Foo()
data class Second(val x: Int) : Foo()
data class Third(val s: String) : Foo()
}
it's not a huge difference but it feels unnecessarily messy to do it the current way (especially when you mix in "no argument" data classes and have to use object/class instead) , and I imagine this is a pretty common use-case for sealed classes. what do you think?marcusfs
11/28/2018, 3:10 PMsealed data class Foo {
First,
Second(val x: Int),
Third(val s: String)
}
instead of this:
sealed class Foo {
object First : Foo()
data class Second(val x: Int) : Foo()
data class Third(val s: String) : Foo()
}
it's not a huge difference but it feels unnecessarily messy to do it the current way (especially when you mix in "no argument" data classes and have to use object/class instead) , and I imagine this is a pretty common use-case for sealed classes. what do you think?orangy
11/28/2018, 3:14 PMenum
, all enum values are singletons.marcusfs
11/28/2018, 3:20 PMorangy
11/28/2018, 3:21 PMvalues
, valueOf
, etc, that assumes all variants are singletons. Using same word for something that is significantly different is very confusing.marcusfs
11/28/2018, 3:23 PMorangy
11/28/2018, 3:23 PMenum
comes from the fact that all values are enumerable
, after all.marcusfs
11/28/2018, 3:24 PMorangy
11/28/2018, 3:24 PM:Foo()
and data class
?marcusfs
11/28/2018, 3:25 PMobject
if you don't have any arguments to a caseclass
i guess)orangy
11/28/2018, 3:25 PMmarcusfs
11/28/2018, 3:29 PMsealed class AddEditTaskEvent {
data class DefinitionCompleted(val title: String, val description: String) : AddEditTaskEvent()
object CreatedSuccessfully : AddEditTaskEvent()
data class CreationFailed(val reason: String) : AddEditTaskEvent()
object UpdatedSuccessfully : AddEditTaskEvent()
data class UpdateFailed(val reason: String) : AddEditTaskEvent()
}
versus
enum data class AddEditTaskEvent {
DefinitionCompleted(val title: String, val description: String),
CreatedSuccessfully,
CreationFailed(val reason: String),
UpdatedSuccessfully,
UpdateFailed(val reason: String)
}
orangy
11/28/2018, 3:38 PMenum
is appropriate shortcut here.marcusfs
11/28/2018, 3:39 PMkarelpeeters
11/28/2018, 11:30 PMenum
in rust, which misses the JVM concept of enum entirely)gildor
11/29/2018, 3:12 AMsealed class AddEditTaskEvent
data class DefinitionCompleted(val title: String, val description: String) : AddEditTaskEvent()
object CreatedSuccessfully : AddEditTaskEvent()
data class CreationFailed(val reason: String) : AddEditTaskEvent()
object UpdatedSuccessfully : AddEditTaskEvent()
data class UpdateFailed(val reason: String) : AddEditTaskEvent()
And used as:
CreationFailed("reason)
instead of
AddEditTaskEvent.CreationFailed
But with implicit sealed class you don’t have such choice.marcusfs
11/29/2018, 9:17 AMgildor
11/29/2018, 9:20 AMEvent.Success
vs SuccessEvent
, you don’t want to have Event.SuccessEvent
, I just pointed that this proposal doesn’t work well with non-nested classesmarcusfs
11/29/2018, 9:20 AMenum
(or enum-with-associated-data as they refer to it) works like rust too. one really frustrating thing about their enum though is that the cases aren't subtypes of the enum type - in fact they are not even types at all and you can only access them using pattern matching.enum Foo {
case First
case Second(Int)
case Third(String)
}
Rust
enum Foo {
First,
Second(int),
Third(String)
}
Haskell
data Foo = First | Second Int | Third String
sealed data classes already have the right semantics for this, it's just that i think the syntax when declaring it is a bit verbose, as i stated abovegildor
11/29/2018, 9:35 AMFirst
, not Foo.First
. i don’t think this would be useful for every use-caseThat’s the problem, you suggest new language feature and new syntax, which is big change itself, so should work for so many cases as it possible Maybe there are some other ways to avoid additional verbosity, but now it’s pretty limited, for example you also want to have constructor properties for parent sealed class, but this syntax doesn’t allow that
marcusfs
11/29/2018, 9:44 AMgildor
11/29/2018, 9:46 AMmarcusfs
11/29/2018, 9:47 AMgildor
11/29/2018, 9:47 AMmarcusfs
11/29/2018, 9:48 AMgildor
11/29/2018, 9:49 AMmarcusfs
11/29/2018, 9:57 AMdata class
is shorthand for a specific kind of class
(namely a product type), i'd really like to see something like a sealed data class
as a complement for supporting sum types.gildor
11/29/2018, 10:00 AMmarcusfs
11/29/2018, 10:01 AMgildor
11/29/2018, 10:01 AM, i’d really like to see something like athis actually interesting addition, maybe this makes more sense, because doesn’t clash with existing implementationsealed data class
marcusfs
11/29/2018, 10:06 AMgildor
11/29/2018, 10:06 AMenum
marcusfs
11/29/2018, 10:06 AMorangy
11/29/2018, 10:08 AMsealed data class
clashes with existing meaning. E.g. if you have inner class
and you make it inner data class
it doesn’t change syntax that radicallymarcusfs
11/29/2018, 10:09 AMorangy
11/29/2018, 10:13 AMmarcusfs
11/29/2018, 10:13 AMgildor
11/29/2018, 10:24 AMeven enums allow bodies after allBut the same body for each item, which may be too restrictive for sealed class (because each item has own types in constructor, so probably want to have own methods)
marcusfs
11/29/2018, 10:25 AMDico
11/29/2018, 10:26 AMsealed data class
. Body of the parent class can follow the ;
just like in enum class (even if I'm not personally a fan of that syntax)enum class
you call the parent constructor instead of declaring a new onemarcusfs
11/29/2018, 10:35 AMlouiscad
11/29/2018, 9:20 PMgildor
11/30/2018, 1:05 AM