3 ms·
"Prolog is a pure functional language ... so there are no variables to update?—?only method calls." It's been a while (some decades) since I wrote my last prol
by stewbrew 16y ago
"Prolog is a pure functional language ... so there are no variables to update?—?only method calls."
It's been a while (some decades) since I wrote my last prolog program but this seems to be rather wrong to me. First of all, there is also the paradigm of logic programming and prolog is it's best known child. I don't think you can equate logic programming to functional programming. Secondly, there are no method calls as such. IIRC a prolog interpreter basically does a depth-first search on a graph made up of assertions. The very point of prolog is though that you don't tell the interpreter "call this method with these arguments and then do that" but rather you tell it "show me valid solutions that fit this template assertion, do however you think is best". At least that's what simple interpreters did. I don't know what more sophisticated compilers like gnu prolog made out of it. Please somebody correct me if I'm wrong. It's possible that my memory fails me.
- tsewlliw 16y agonot that depth first search isn't a pretty good analogy for what happens, but I believe it's SLDNF resolution, and I'm not 100% sure the exact algorithm is mandated by the language, though it might be for cuts.
- _tef 16y agoprolog is actually impure logic language, and given the general lack of HOF i'd be reticent in labelling it functional. it's a declarative language though, and the model you have 'here is a query, what solutions exist' is reasonably accurate
- danieldk 16y agoThere is a subset called "pure Prolog", which is restricted to Horn clauses. But regular Prolog (with extralogical features) is not functional, and definitely not pure. For instance, the proof_me predicate in the following program will be true, only once: :- dynamic bla/0. proof_me :- \+ bla, assert(bla).
- Dn_Ab 16y agoI don't know prolog but it seems to operate on relations and not functions. So my guess it that you are right and it is not a functional language.