3 ms·
This is far less readable than Java streams to me. sum(filter(x->x%2==0,List.of(5,3,4,19,75,6))); Streams are formatted linearly similar to Clojure threadin
by nogridbag 3y ago
This is far less readable than Java streams to me.
sum(filter(x->x%2==0,List.of(5,3,4,19,75,6)));
Streams are formatted linearly similar to Clojure threading macros.
- PaulHoule 3y agoThe advantage of the static import DSL is that it is more composable: anyone else can define operators that interoperate with my operators without the complexity of the scheme linked above not to mention more generality. This goes not just for the low level operators like "filter" that you might want to supplement but the many more operators you can write that are implemented out of mine. I prototyped an API that works in the same direction as streams by having something like https://paulhoule.github.io/pidove/apidocs/com/ontology2/pidove/iterables/TidyIterable.html https://paulhoule.github.io/pidove/apidocs/com/ontology2/pid... in that it wraps all Iterables returned by my methods and has not just the teardown facility but also all the operators attached as instance methods which lets you write the chaining style you ask for that I know is in demand. If I was going to go any further on pidove it would have involved more use of code generation and this system https://github.com/paulhoule/ferocity https://github.com/paulhoule/ferocity which was supposed to be a code generator for writing code generators, and it could code generate stubs that would let you write expression trees in Java as S-expressions and build them up into methods and either compile the code to real Java source code or execute the methods by evaluating the expression tree in place. Like common LISP you can write syntactic macros in that that metalanguage because an Expression<Expression<X>> can be evaluated at compile time, one of quite a few concepts like "quoting" that I encountered in that spike. The idea was ferocity would get to the point where it synthesizes a more complete and perfect pidove.