```with(vk) { this@create.enumerate() }```
# announcements
d
Copy code
with(vk) { this@create.enumerate() }
e
yeah I know, but it's crap. I'm using that intensively and I'd like to keep the syntax as much as possible close to cpp. Is there another way? Rearrange
vk
is not a problem
d
Just don't use instance extension functions at all unless you're making a dsl. That's my advice.
e
I came out with this:
Copy code
class Dev 

fun Dev.a() = 3

interface I {
    fun Dev.a() = 2
    fun v.b() = 2
    fun a() = 4
}

class Sta : I



fun Sta.main() {
    val device = Dev()
    device.a()
    v.b()
}

fun main() {
    val device = Dev()
    device.a()
    v.b()
}
d
This looks incredibly error prone.
e
a()
and
b()
will of course be redirect to the same root function
but the most important thing is that by simply adding o removing the
Sta
receiver, I will use the corresponding functions
d
You shouldn't control this from the declaration of your function, you should control this using dependency injection. Remove the globals, always use the Sta receiver and add a different implementation for the globals. Your code will be a lot more composable and way less error prone.
e
My goal is to simply add a receiver to the hot functions in order to quickly get rid of many small overhead (not retrieving the stack for each native API call) without modifying your code further
d
Ok