code-reviews

john 2018-11-17T20:36:37.067900Z

what do y'all think about this for quick and dirty predicate dispatch? https://stackoverflow.com/questions/53329709/dispatching-function-calls-on-different-formats-of-maps/53354967#53354967

john 2018-11-17T20:37:26.068500Z

I'm not as conversant in macros, so it's probably pretty buggy

jaihindhreddy 2018-11-17T21:07:27.071600Z

@john it seems because you're using a {} to store the impls, when a value satisfies multiple predicates, which one gets dispatched is random, isn't it? How about (def poly-atom (atom (array-map)))? That way we can implement prefer-method? This is first time I've seen predicate dispatch so I have no idea what I'm talking about.

john 2018-11-17T21:27:27.076Z

@jaihindh.reddy I updated the example a bit, to read a bit clearer. Particular polys, like myincs or take-turns are stored as keys in the map. Their predicate implementations are conjed to a vector of vectors which contain pairs of predicates and functions, which apply to the params when the predicate returns true with the params.

john 2018-11-17T21:28:28.077100Z

prefer-method enhancement would need to replace the filtering functionality that runs over those pairs

jaihindhreddy 2018-11-17T21:28:35.077400Z

Oops. The comment cleared it up. Got it.