Haxe

Haxe 2 から 3 へ

Haxe のバージョンを 2.10 から 3.0.0 に更新した。 Haxe 2 の時のコードが結構動かなくなったので、変更点をメモ。 interface 継承の変更 implements -> extends haxe 2 interface Hoge {} interface Piyo implements Hoge {} haxe 3 interface Hoge {} int…

型パラメータとミックスイン

Mix.hx interface A {} interface B {} class C implements A, implements B { public function new() {} } class Mix { public static function hoge(x: A) {} public static function piyo(x: B) {} } Hoge.hx using Mix; class Hoge { public static func…

構造体と型

typedef X = { id: Int, name: String } class Hoge { public static function hoge(x: X) {} public static function main() { hoge({ id: 0 }); } }これはエラー。 $ haxe hoge.hxml Hoge.hx:5: characters 7-16 : { id : Int } has no field name Hoge.hx…

関数の型

var f: Int -> Int -> Int = function(a, b) { return a + b; }; var g: Int -> (Int -> Int) = function(a) { return function(b) { return a + b; }; }; var h: (Int -> Int) -> Int = function(f) { return 0; };えー。

type 演算子?

プログラム中のどこでも,ある表現の型を知るためには,type 演算子を使うことができます。コンパイル時に,type 演算子は除去され,表現だけが残ります : var x : Int = type(0);この例ではコンパイル時に Int と表示され,type が使われなかった場合と同じ…

Haxe

仕事で Haxe を使うようになったので、はまったとこなどのメモを少し残しておく。 使っているバージョンは 2.10 で、JS 吐き出し用。