I’m looking for pointers on how to achieve the following behaviour. I want to have a dictionary that has a key type and an atom value denoting the “implementation module”. Now, in the dictionary tag module, I would define a function that needs to do some kind of dynamic dispatch - first check if type:function is defined, if yes, call it - and if not fall back to a default implementation.
Example:
inventory{type: book, ...}.url() would look for url function in the book module first and call it if it’s defined, otherwise just call some default implementation.
I know that pce offers objects and inheritance but I don’t need OOP-like state, as the state is already in the dictionary.
@jamesnvc I wanted the url predicate in inventory module to actually call url in book (or whatever is the type key of my inventory dictionary holds) if defined - for a very simple inheritance-like behaviour. That’s why I did the wrapper solution above.