Youssef Shoaib [MOD]
05/28/2023, 3:56 PMRaise
interface they're boxed, but it's not really explained anywhere in the PR as to why that happened.simon.vergauwen
05/28/2023, 4:14 PM@JvmName
Youssef Shoaib [MOD]
05/28/2023, 4:15 PMsimon.vergauwen
05/28/2023, 4:16 PM@JvmName
Youssef Shoaib [MOD]
05/28/2023, 4:17 PM@JvmName
errors out inside value classes. That's truly annoying. It feels like JvmName should have better compatibility with the language features (like interfaces for instance)Youssef Shoaib [MOD]
05/28/2023, 4:18 PMJvmMultifileClass
? Is it a nice-to-have? For better logs perhaps?simon.vergauwen
05/28/2023, 4:23 PMFlow
) into a single class.
It’s a nice to have really. It results in slightly nicer logging, slightly smaller binary footprint afaik. Nothing major.simon.vergauwen
05/28/2023, 4:24 PM@JvmName
from interfaces or value classes but I always thought this was due to technical limitationsYoussef Shoaib [MOD]
05/28/2023, 4:25 PMmerge(Raise.() -> Blah
that's analogous to Effect.merge
and it conflicted) so I was curious why it was there.Youssef Shoaib [MOD]
05/28/2023, 4:26 PMJvmName
simon.vergauwen
05/28/2023, 4:26 PMEffect
is the same than a Raise
lambda, and the receiver becomes the first argument 😅Youssef Shoaib [MOD]
05/28/2023, 4:27 PM@JvmName("_merge")
. At least that's how fold
does itsimon.vergauwen
05/28/2023, 4:27 PMabstract class
🤔 I don’t use that often, het should remember that.simon.vergauwen
05/28/2023, 4:27 PM_
but these inline methods are not useable from Java anywayYoussef Shoaib [MOD]
05/28/2023, 4:28 PMJvmName
simon.vergauwen
05/28/2023, 4:29 PMnon-inline
methods because the signatures were ambiguous on JVM but it compiled fine.
It was in a mixed with Scala codebase though 😅Youssef Shoaib [MOD]
05/28/2023, 4:29 PMfold
since _fold
does the exact same thing with the same signatureYoussef Shoaib [MOD]
05/28/2023, 4:30 PMEffect
and EagerEffect
code could go away if kotlin just supported inlining receiver lambdas, but alas.Youssef Shoaib [MOD]
05/28/2023, 4:34 PMJvmName
that works with interfaces: https://github.com/Kotlin/KEEP/blob/binary-signature/proposals/multiplatform/binary-signature.mdsimon.vergauwen
05/28/2023, 4:39 PMEagerEffect
and Effect
could go away and it’s kind-of possible with context receivers if we had them 😅
But I’m also curious how that’ll actually be used in practice compared to just returning Either
. The nice thing is that both can live alongside each other perfectly.
Still inlining lambda receivers is something I’ve though about, but I cannot really put into words how it’d want it to actually work in the language 😅 😅 😅Youssef Shoaib [MOD]
05/28/2023, 5:03 PM.
is viewed as depending on its receiver, and not influencing its receiver, and so you can only really have functions on lambdas if those lambdas are pre-existing values, but then those values can't really be inlined. That's why extension lambda receivers for inline functions are treated as noinline
With the risk of derailing the discussion too much:
if the compiler had some sort of way to declare values that shouldn't escape an inline context (similar to how an inline method with an inline lambda parameter can't have that lambda escape) then you can have "local lambdas" that act as values, and hence they'd only be allowed to be passed to inline functions. This allows for viewing data as "curried functions", ala church encoding, and you can have zero-cost struct-like types. I made that as a suggestion a while back, but after having a go at implementing it, it definitely is too big of a hassle, and results in frequent compiler crashes because it just wasn't designed to inline such deeply-nested code.
One "easy"-ish way for the compiler to support this would be with a new modifier similar to crossinline
(maybe inline
) that declares that this lambda parameter is an inline
function w.r.t its lambda parameters. An example helps:
inline fun <T, R1, R2> letLambda(lambda: (T) -> R1, inline block: ((T) -> R1) -> R2) = block(lambda)
here inline
declares that the block is, for all intents and purposes, an inline function, and so at the callsite you'd be defining an anonymous inline function. You'd also only be able to use callable references to other inline
functions. This introduces a name for the lambda parameter inside without actually storing the lambda as a real object. Then, an extension on such a lambda would make sense, and by extension, it would justify having EagerEffect.fold
being inline and hence applying to Effect
as well (in suspending contexts only obviously).