4 ms·
This example shows that Clojure list comprehensions (the for... syntax) have much of the expressive power of logic programming (the first... syntax). List comp
by TimSweeneyEpic 3y ago
This example shows that Clojure list comprehensions (the for... syntax) have much of the expressive power of logic programming (the first... syntax).
List comprehensions support a bundle of features including producing multiple values, and filtering them by testing and potentially failing.
Logic programming is that plus some more flexibility (more compositional forms of multiple value production) and some new features (such as using unification to solve for unknowns).
We should expect mainstream languages to evolve to support more logic features, since they provide a more general and more compositional way to do many things. Pattern matching expressions in most languages are a limited special case of logic programming that would benefit from using the more general case. Same with casting constructs, null propagation operators, boolean and/or/not, and the internal compiler logic supporting features like Haskell typeclasses and Rust traits. If we can replace lots of special-case language features a few general constructs, programming will be simpler as Niklaus Wirth advocates for.