3 ms·
What is an expression tree? I've done this with arrays of structs in C as well as nested dictionaries in python, and sexps in both lisp and python. I could do i
by emidln 7y ago
What is an expression tree? I've done this with arrays of structs in C as well as nested dictionaries in python, and sexps in both lisp and python. I could do it trivially in x86 if needed. Maybe sexps are "expression trees", but it seems almost any language can implement this pattern. It was much nicer with data literals than without, but data literals aren't a prerequisite.
- jdmichal 7y agoExpression trees are a .NET capability to compile a series of expressions during runtime. It's not required for this at all; it's just an optimization. It allows the complex tree of Specification objects to be compiled down into a simple delegate function, rather than evaluating by walking the tree.
- NicoJuicy 7y agoWell, then your use-case is different than mine. Since I mostly use specification pattern on top of a orm layer. Orm's support expression trees ( eg, nhibernate,...) So the specifications pattern for my use-case require expression trees. There are workarounds ofc, but translating specifications to Sql is not the desired use-case of the pattern. Specifications make it easy to have a 100% equal business filter ( that translate it to Sql through the ORM) and making it testable. - Specification.AssertAll(resultset, "not all elements are valid according to this specification"); ( Using pseudocode )