HaxeFoundation / HaxeFoundation/haxe
Inline differences
- Dominant language
- Haxe
- Stars
- 6.9k
- Forks
- 715
- Avg merge
- 2d 2h
- Merged PRs (30d)
- 11
Description
First of all thx for the great inline improvements. I was playing around with it and had an interesting result, not sure if the result is how it should be. The result with final is great, but i don't understand why some of the other ones are not as good as that. This is the example code:
```haxe
interface Show {
function show(fa:T):String;
}
class ShowApi {
public static inline function show(a:A, ?S:Show) {
return S.show(a);
}
}
class ShowInt implements Show {
public inline function new () {}
public static inline function instance1 () return new ShowInt();
public static var instance2 = new ShowInt();
public static final instance3 = new ShowInt();
public static var instance4(default,null) = new ShowInt();
public inline function show (a:Int):String {
return "" + a;
}
}
class Test {
static function main() {
trace(ShowApi.show(1, ShowInt.instance1()));
trace(ShowApi.show(1, ShowInt.instance2));
trace(ShowApi.show(1, ShowInt.instance3));
trace(ShowApi.show(1, ShowInt.instance4));
trace(ShowApi.show(1, new ShowInt()));
}
}
```
the resulting js:
```js
console.log("Test.hx:28:",new ShowInt().show(1));
console.log("Test.hx:29:",ShowInt.instance2.show(1));
console.log("Test.hx:30:","" + 1); // great, final optimization?
console.log("Test.hx:31:",ShowInt.instance4.show(1));
console.log("Test.hx:32:",new ShowInt().show(1));
```
Contributor guide
Assessment
This issue has not been assessed yet.