[quote=“pys, post:15, topic:2127”]
Yes, that’s what all languages do. They magically create machine code that the processor can execute.
[/quote]To me there is a difference between creating anonymous objects out of thin air and translating the actual code. So the nuance is important here.
[quote=“pys, post:15, topic:2127”]
I understand that this is what you prefer. This does not make it right unless you give meaningful arguments.
[/quote]Certainly agree. Yet we are talking preference here, you simply prefer something different. [quote=“pys, post:15, topic:2127”]
A lazy value should be evaluated when the value is used. Not when it’s reference is used. And a “lazy” A should be an A, so it should be possible to use it everywhere and A is expected without any syntax change.
[/quote]Why should that be the case? It’s just your interpretation of “when it’s used”. I can easily argue that a value being passed as an argument is “being used”. An issue with late lazy evaluation might be that you might keep it’s parent object strongly referenced for way too long. See the following (naive) example:
class Foo {
val a by lazy {bar()}
fun bar() = 3
fun baz(callback : (Int) -> Unit) {
callback(a) // if a is lazy evaluated we're now leaking the whole object Foo
}
}