Live data from Hacker News

Show HN: Prolog compiler and interpreter in pure JavaScript

prolog.jldupont.com

1–5 of 5 posts

Re: Show HN: Prolog compiler and interpreter in pure JavaScript

#4
post #3

?- X = 10. X = _ no. ...this doesn't work like any Prolog I know. (Even defining equality manually as "eq(X, X)." doesn't work...)

Why? `?-` indicates that it's a query, it should not define anything.

    $ swipl
    ?- X = 10.
    X = 10.

    $ gprolog
    | ?- X = 10.
    X = 10
    yes
(a) The REPL should print the variable bindings which caused the query to succeed. (b) The query `X = 10.` should succeed trivially.

I've been using Prolog on-and-off for close to a decade now and have implemented my own pseudo-Prolog (also in Javascript; was missing logic variables and extra-logical builtins). I tried to get pretty much any query to succeed in this interpreter and couldn't. This is not any kind of Prolog that I'm familiar with.

Re: Show HN: Prolog compiler and interpreter in pure JavaScript

#5
post #3

Earlier quoted context omitted.

Why? `?-` indicates that it's a query, it should not define anything.

$ swipl ?- X = 10. X = 10. $ gprolog | ?- X = 10. X = 10 yes (a) The REPL should print the variable bindings which caused the query to succeed. (b) The query `X = 10.` should succeed trivially. I've been using Prolog on-and-off for close to a decade now and have implemented my own pseudo-Prolog (also in Javascript; was missing logic variables and extra-logical builtins). I tried to get pretty much any query to succee…

Yep, I agree I was wrong (having too little experience in Prolog): variables are necessary to extract values from queries.