Wow, excellent answers and guidance. Thank you so much!
This is a situation where I can seriously improve my Haxe skills just by executing the changes indicated by you.
@back2dos I am curious why you think that reflection is a “legacy” thing and not required. I do try to stay away from it, but here’s a situation I just experienced where I can’t figure out a good way to get rid of it:
I’m building a filtering system that involves, among others, two very different filters. Hierarchical (similar to let’s say a package structure or log4j) and Array-based (similar to let’s say the way you set your log levels in log4j). Ok so these two filters have a common ancestor, but not much else can be shared. Both filters implement an interface FilterI
that ensures they have a match
function. But the logic of the match
function is of course very different between the two as they have different data structure. The problem appears when I’m trying to match a filter of one type against another one (a match results in a “find”).
I just typed another 2 long paragraphs to explain the issue to you and just as I was almost done, I realized “oh wait, I can declare an enum
in the interface and each filter will set itself as a member of the enum and then I’ll just match against the enum in the match
function problem solved closing quote”.
But seriously, why do you say it’s a legacy thing?