So if my understanding is correct, the RethinkDB driver translates a Python function object into its "abstract interpretation" by invoking the function on a proxy object x that defines operators such that (simplifying) x.__op__() returns Op(x). Recursively, this yields the computation tree of the function. This looks very similar to what is done in C++ metaprogramming through "expression templates", a technique that is taken to its extremes in libraries such as Boost.Proto. C# solves this more cleanly by having in the language an explicit concept of "expression trees" that are given as arguments of LINQ queries.<p>I wonder if this imposes any limitations on the functions that can be written. For example, how are if, for statements handled? What happens if I do "lambda x: y + x" where "y" is an object that defines __add__? If these cases are not handled, is a well-defined exception raised?
Well this is just lovely! It's so similar and such a good fit for what we're doing in Delver (we build very similar abstract queries out of natural language, but for compilation into SQL etc) that it makes me want to force everyone to use RethinkDB. Our lives are maybe a little easier cos we do it in Clojure so it's s-expressions in, s-expressions out.<p>Can't see much evidence of a clojure driver yet? Is there an existing project we could contribute to?
and thus we learn that RethinkDB is an elaborate scheme to get programmers to learn Higher Order Abstract Syntax techniques, not just have a neat db :)<p>Hoas, and its sibling PHOAS, are great ways of embedding a mini language inside another language, they're especially powerful in language like Haskell, Scala, Idris, and the like.
That is genius.<p>I have to wonder though, how they plan to do it in less dynamic languages? Just spell out the s-expr and forget about using the language's own syntax?