AureumChaos/LEAP

Replace Primitive class with inspection

Opened this issue · 1 comments

In #234, we introduced an optional class hierarchy for genetic programming primitives to allow a small optimization. But all these classes do is allow the arity of primitives to be queried.

@markcoletti points out that we could us reflection via inspect to access this information instead—eliminating the need for the class rappers.

I like the concept of this, although it would conflict with default arguments if they aren't considered as inputs to the function. From what I can find you can detect / extract default arguments fairly easily, but more exotic methods like curry or partial would probably still conflict. Maybe inspect as a default, but have a way to override the arity?

Edit for reference on detecting default parameters: https://stackoverflow.com/questions/12627118/get-a-function-arguments-default-value