haxetink / tink_core

Core utilities
https://haxetink.github.io/tink_core
MIT License
118 stars 33 forks source link

use function field instead of dynamic function #133

Closed nadako closed 4 years ago

nadako commented 4 years ago

the difference is that dynamic function is $bind-ed in drain, while a functional field isn't and since we don't need binding we can save a couple ticks

back2dos commented 4 years ago

Cool, thanks ;)

I wonder though if this kind of "optimization" isn't the compiler's job ^^

nadako commented 4 years ago

Yeah, I already created some issues specifically while experimenting with Futures, e.g. this one seems related: https://github.com/HaxeFoundation/haxe/issues/9268

back2dos commented 4 years ago

Well, yeah, but the other one is quite tricky.

My point is that $bind on dynamic functions seems stupid. In the rare cases where the default implementation needs access to this, the compiler should deal with it, e.g. by emitting this.method = $bind(this, this.method) in the constructor. Other than that, it should always be plain field access.

nadako commented 4 years ago

this.method = $bind(this, this.method)

That is a good point actually, I'll make a haxe issue about this :)