https://kotlinlang.org logo
#stdlib
Title
j

jimn

02/07/2020, 5:53 AM
i dismissed a notice of
A.(B)->C
when i came upon a random refactoring intent having reverted it after testing it and seeing it worked all the same. https://kotlinlang.org/docs/reference/lambdas.html#function-literals-with-receiver as it turns out is a real thing. so there are a few quirks about stdlib, gaps between say list and array which appeear to be interchangable but are not(unless i write them). and likewise for the primitive arrays and the object arrays. is there an undercurrent of some java-generics like algebra that spoils it for writing a suite of generic extensions for the existing base kotlin libs?
could
fun<X,T,R> X<T>.iterator(Unit)->(R)
exist for instance for filling the gap between iterable and sequence?
i

ilya.gorbunov

02/07/2020, 6:39 AM
You mean, abstracting/generalizing over convention, e.g. writing a function that takes anything that implements "iterable" convention? No, it can be achieved neither with generics nor the other language constructions.
j

jimn

02/07/2020, 2:58 PM
Copy code
No, it can be achieved neither with generics nor the other language constructions.
is that a double or triple negative? does this mean "cannot" be achieved?
r

Ruckus

02/07/2020, 4:44 PM
@jimn It was perfectly correct. Both the following constructs are equivalent: • cannot x by a or b • can x by neither a nor b
1
j

jimn

02/08/2020, 7:06 AM
@Ruckus thank you for helping with the clarification of his intent. while that may be a logical and proper English construct found in the likes of Noam Chomsky dissertations or Tolkien literature, it's not even a rarely used construction in common online communication. it looks like a cut and paste error tbh worthy of double checking
apparently ad-hoc polymoprphism is mostly addressed in this KEEP https://github.com/Kotlin/KEEP/pull/87 which seems like a pretty relevant bit of info to add to this thread
3 Views