Letting interprete also consume functions as well as protocols would
let it bottom out into actual clojure code that actually implements
some logic.
Though it would also be handy so have some kind of (escape [bindings]
body) clause to allow binding to normal code to temporary names for
the sake
The defmulti would be closer to
(defmulti mm first)
because we need to dig into the list to get the first symbol.
I don't think that there is anything stopping you from creating such a code
walker now. Maybe you should built a proof of concept to demonstrate some
use cases
This is a pretty embryonic idea, but I'm wondering if anyone has
thought the same, or seen relevant examples/literature.
The idea is: What if we could attach protocols to symbols themselves?
so (foo '(bar 1))
would have its behavior defined by a protocol implemented on the symbol bar.
This
one example use case: validating expressions
(valid? '(foo (bar 1))) - protocol implemented by foo decides if it
likes its argument structure
various semantics about the symbol can be encoded in the protocols.
On Tue, Jan 8, 2013 at 1:56 AM, kovas boguta kovas.bog...@gmail.com wrote:
This is
Close.
The defmulti would be closer to
(defmulti mm first)
because we need to dig into the list to get the first symbol.
But there need to be a way to recurse as well, if you want to
interprete the whole expression. That part is hard to capture in the
multimethod.
(interprete '(foo (bar 1)))
Maybe the use cases would be more clearer if I fleshed out the
interprete operation.
The typical case would be
(interprete expression [protocol1 protocol2 protocol3 ...])
interprete would limit its operation the protocols specified;
everything else would be inert.
To implement compiler passes,