haxe-dev: Tales from within

Simon Krajewski
WWX 2016

Overview

People: Here (1/2)

People: Here (2/2)

People: Here (3/2)

People: At home (1/2)

People: At home (2/2)

Road to Haxe 3.3: Recipe (1/2)

Road to Haxe 3.3: Recipe (2/2)

import.hx: Scenario

import.hx: Usage

@:structInit: Introduction

@:structInit: What we want

@:structInit: What we have

@:structInit: What it does

@:structInit - Evaluation order

@:structInit
class MyStruct {
	public var a:Int;
	public var b:Int;
}

class Main {
	static var i = 0;
	static function call() return i++;
	static public function main() {
		var m1:MyStruct = { a: call(), b: call() };
		var m2:MyStruct = { b: call(), a: call() };
	}
}
new MyStruct(Main.call(),Main.call());
var _g1 = Main.call();
new MyStruct(Main.call(),_g1);

@:structInit - @:optional fields

@:structInit
class MyStruct {
	@:optional public var a:Int;
	public var b:Int;
}

class Main {
	static public function main() {
		var m1:MyStruct = { b: 12 };
		trace(m1.a); // null/0
		trace(m1.b); // 12
	}
}
var m1 = new MyStruct(null,12);

Static Analysis - Getting started

Static analysis - Example

class Main {
	static function main() {
		var x = 1;
		if (x == 2) {
			throw "Critical exception";
		}
		trace(x);
	}
}

Static analysis - Justification

Static analysis - Control flow

class Main {
	static function main() {
		var x = 1;
		if (getBool()) {
			x = 2;
		} else {
			x = 2;
		}
		trace(x);
	}

	static function getBool() {
		return true;
	}
}

Static analysis - Observation

Static analysis - What it does

The future

Thank you!