Skip to content

Instantly share code, notes, and snippets.

@serjek
Created October 15, 2020 17:50
Show Gist options
  • Save serjek/48042dd9503464c1fdc0d144eb87afc4 to your computer and use it in GitHub Desktop.
Save serjek/48042dd9503464c1fdc0d144eb87afc4 to your computer and use it in GitHub Desktop.
package;
import haxe.macro.*;
using haxe.macro.Tools;
using StringTools;
using Lambda;
class TestMinimal {
static function main() {
var m = new N(); //new M(); - this gives compilation error indicating that coconut magic was not applied
tracem(m.a);
}
public static macro function tracem(e:Array<Expr>) {
final desc = prettyString(e.map(v -> v.toString()));
var expr = macro {
trace($v{desc} +': '+ prettyString(($a{e}:Array<Dynamic>)));
null;
}
return macro $expr;
}
static function prettyString<T>(arr:Array<T>, ?sep:String = ', '):String
return arr.fold((a,b) -> b + (b == "" ? "" : sep) + a,"");
}
class M implements coconut.data.Model {
@:observable var a:String = "okay";
}
class N {
public var a = "okay";
public function new() {}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment