COMMUNITY

How objects with fields which are haxe keywords should be defined?

For instance how define such objects {default: true} or {in: true}?
Is it possible to give an alias for a typedef field?

I would use Reflection to do this

https://try.haxe.org/#9c64c

@:native (on extern types) can help: https://try.haxe.org/#EfB9D

Thanks. But Dynamic is not very elegant solution. What if you need define the object {field1: Bool, field2: Bool,..., fieldN: Bool, default: Bool}?

Thanks for reply. But the code compiles to var o = new MyType(true,false);, but I need output like this var o = {default: true, in: false}

Is something like this will help?

https://try.haxe.org/#4f8d9

Use double quotes for such fields: {"default":true, "in": false}
https://try.haxe.org/#8e9Fe

Yep, using of abstract can solve this issue. Thank you.

1 Like

FWIW, this proposal, once implemented should address this nicely.