ilya.gorbunov
09/05/2018, 11:41 AMbuildSequence
and buildIterator
functions. Please share your thoughts regarding the names proposed in the attached post, especially if you find something confusing about any of them.
Slack Conversationtoxara
09/05/2018, 1:08 PMdefine*
makes the most sense semantically. Another good option might be generate*
.ilya.gorbunov
09/05/2018, 1:09 PMgenerateSequence
is already used for recurrent definition of a sequence: generateSequence(initial) { e -> next(e) }
Daniel Tam
09/05/2018, 3:53 PMdave08
09/05/2018, 4:13 PMyieldSequence
? it would clearly show the suspending nature of how the sequence is generated. Even though that differs from other builders out there, but that really is its distinguishing point, no?ilya.gorbunov
09/05/2018, 4:47 PMyield
is a suspend function that is used to output a value or several values to sequence (yieldAll
). It would be very confusing to reuse it in a non-suspend context to name yieldSequence
.dave08
09/05/2018, 4:49 PMdave08
09/05/2018, 4:50 PMbdawg.io
09/05/2018, 8:32 PMsequenceOf
providing a population function. Then it would be easy to provide iteratorOf
. You could even expand this to provide mapOf { yield("a" to "b") }
and other variants 🤷Dominaezzz
09/05/2018, 8:43 PMdefineSequence
is the least confusing.dave08
09/06/2018, 10:10 AMsequenceFrom
, it might be nice to also have listFrom
, etc..., I just had a use case recently building a list out of optional function parameters... I had to do buildSequence { param1?.let { yield(it) }; ... }.toList()
ilya.gorbunov
09/07/2018, 3:54 AMsequenceFrom
can be confusing is when the type parameter is specified explicitly:
val empty = sequenceFrom<String> { }
val supertypes = sequenceFrom<Supertype> {
yield(subtype1)
yield(subtype2)
}
dave08
09/07/2018, 7:22 AMlazySequence { }
? Instead of using new terminology (define
which seems to be the only possibility that won't overlap with existing functions, or cause these kind of confusions...), lazy is already used in kotlin for by lazy { }
, wouldn't it be better? @ilya.gorbunovdave08
09/07/2018, 7:23 AMlazyList { }
etc...bdawg.io
09/10/2018, 3:02 PMyield
. I have many buildSequence
operations that does some expensive processing and then performs yield in a loop of output based on that processing. That being the case, I’d be surprised to find lazySequence
blocking my current thread while the iterator gets the next value when I expected it not to happen until I try to consume it on a worker threadilya.gorbunov
09/10/2018, 9:59 PMilya.gorbunov
09/12/2018, 2:35 PMsequence
and `iterator`: https://github.com/JetBrains/kotlin/compare/93b1620708e0a5339bd3fe13f51f76cde2f65958~2...93b1620708e0a5339bd3fe13f51f76cde2f65958dave08
09/12/2018, 2:38 PMlist { }
, map { }
, etc... will also get in @ilya.gorbunov?dave08
09/12/2018, 2:39 PMlistOf
and mapOf
...ilya.gorbunov
09/12/2018, 2:40 PMbuild
prefix, such as buildString { }
. Though that is not set in stone yet, and can be discussed later.
https://youtrack.jetbrains.com/issue/KT-15363dave08
09/12/2018, 2:41 PMyield
... since currently I've had a few use cases that I used buildSequence { ... }.toList()
...dave08
09/12/2018, 2:43 PMdave08
09/12/2018, 2:44 PM