Re:All about lambda functions in RethinkDB queries
by JulianMorrison on Friday May 24, 2013 @05:50AM
(#5761978)
It wouldn't be hard to have a very shallow translation from a lisp-alike syntax - to borrow Clojure's: "(fn [a b] (+ a b))". Named parameters translate trivially to (var n).
The actual underlying S-expression syntax for ReQL lambda functions is pretty ugly by itself and I'm glad that so far we haven't had to expose it. The python `lambda x,y: x + y` actually gets compiled to something like the following: `(func [1,2] (add (var 1) (var 2)))`. Variable references have to be constructed manually no matter how you do it. With native lambda functions though you can at least hide those constructions behind the scenes and bind them to the function's formal arguments.
Fortunately though both C++ and Java, the two "traditional" languages we would most like to support, have either just (in C++11) or are about to (in Java 8) introduce lambda functions rendering the point moot.