Macro for accessing deeply nested properties

Hi all!

I’d like to use a macro, which would allow access deeply nested properties or return default value or raise an exception containing where access has failed.

We implemented similar functionality for Dynamic data structures using reflect, but obviously it lacks static type checking and existence of the fields can’t be checked during compilation time.

My colleague tried to implement this macro and got some basics done, but since we don’t have enough experience with Haxe macro (and probably even full understanding) we are not sure what would be the best approach for this.

Also I may assume that this functionality is already available in some library.

Could anyone suggest how to address this or maybe suggest a library, if this is implemented already?

Big thanks in advance!

Safety library has similar feature:
For obj!.field expression it returns obj.field value or null if obj is null.
Here is the code, which transforms obj!.field:
Maybe that could give you a hint

1 Like