3 ms·
Can someone explain why it is called a "functional" language? Wikipedia says it's essentially a pure subset of Prolog, but Prolog is not classified as a functi
by quelltext 6y ago
Can someone explain why it is called a "functional" language?
Wikipedia says it's essentially a pure subset of Prolog, but Prolog is not classified as a functional language, so I'm curious what makes this one called a functional language.
I assume there must be some significant language features that e.g. functions.
- riffraff 6y agoI think the difference is that in Prolog you have imperative state management while Mercury only has pure functions, and manages state through linear types. EDIT: the "about" page may explain this a tad better https://mercurylang.org/about.html https://mercurylang.org/about.html
- jfmc 6y agoAnother difference between Prolog and Mercury is that Mercury lacks 'real' unification. Predicates must be moded (they must be compiled for some particular variable instantiation states). The compiler reorders literals in a way that free variables do not need to be represented in memory. Almost all the 'logical' side of the language is discarded statically at compile-time. The first time that I tried it (+ 20 years ago!) executables were blazingly fast! The bad side (at the time) was poor flexibility and very slow compilation time (compared with Prolog).
- lars512 6y agoOf course, for any prolog program of significant size, you want nearly all of it to be moded and deterministic anyway, and not leave choice points all over the shop.
- toolslive 6y agoIndeed. Mercury has a really powerful static type system, while prolog hasn't.
- dragonwriter 6y ago> Wikipedia says it's essentially a pure subset of Prolog, but Prolog is not classified as a functional language That statement used “pure” in the sense of “functionally pure” (I'm not sure about “subset”; it certainly lacks some prolog features that are impure, but seems to have features that Prolog lacks; it seems more like it contains a pure subset of Prolog than that it is one.) > I assume there must be some significant language features that e.g. functions. I think you missed something I. that sentence, but, yes, Mercury has first-class and higher-order functions.
- mpweiher 6y ago> Can someone explain why it is called a "functional" language? Not sure why the title only includes "functional", the site itself says "Mercury is a logic/functional programming language".