The Simplicity of Prolog
121–130 of 134 posts
Re: The Simplicity of Prolog
#122Earlier quoted context omitted.
> Predicates are trivially called, even as variables, with the `call/N` metapredicate. Yes, that is the definition of "predicates are not first class values". Some things can be called without call/N. Other things can not be called without call/N. These are two separate classes of things. Both of these classes cannot be the first class.
I think there is some confusion around what is "first class" in Prolog. Any syntactically valid construct in (ISO-conforming) Prolog is "first class", including the symbols that are the names of predicates. The fact that Prolog is a homoiconic language makes any valid Prolog code "first class". "First class" meaning, can be the arguments to a predicate or processed as data. Predicates (and only predicates) can be cal…
First class data, yes. First class predicate, no.
> Predicates (and only predicates) can be called with `call/N`
Some class of things that you apparently refuse to call "predicates" can also be called, but without having to use call/N.
> Perhaps you mean, [...]
No. I mean there are first-class callable things and second-class callable things, and second-class things are not first class.
Re: The Simplicity of Prolog
#123Earlier quoted context omitted.
SWI Prolog 7 added "X = Dict.key" syntax and that use of "." makes it fundamentally incompatible, ISO standard breaking, backwards incompatible to previous Prologs, sideways incompatible to other Prologs. This is a worse sin in Prolog than it seems at a glance, because one of the strengths Prolog has is code-is-data / data-is-code metaprogramming. That includes exporting code as Prolog terms (use cases you might use…
> SWI 7 can't guarantee to read all SWI 6 code > Code written 30 years ago which uses the dot in the old standard way might trigger SWI to try and read it in the Dict.key way and fail. Why would they do that? SWI 7 reading SWI 6 or ISO prolog code should be rather trivial, shouldn't it?
?- X = '.'(1,'.'(2,'.'(3,[]))).
X = [1,2,3].
SWI Prolog 9: ?- X = '.'(1,'.'(2,'.'(3,[]))).
ERROR: Type error: `dict' expected, found `3' (an integer)Re: The Simplicity of Prolog
#124Earlier quoted context omitted.
There is Datascript. I am not a Clojure guy, so it is not clear to me if it pulls datomic as a dependency.
Datascript is very similar to Datomic, except that it runs in ClojureScript and is an in-memory datastore with no concept of history or point-in-time queries. The schemas are also much looser than Datomic. Otherwise, many syntax and semantics are similar. No dependency on Datomic as Datomic is Java and DataScript is JavaScript.
Re: The Simplicity of Prolog
#125Am I the only who finds this article to be inaccessible due to color choices and implementation? I'm really interested in Prolog, but my eyes feel the strain after a few sentences. The reason is that the contrast ratio of some parts is very low, of others excessively high. The constant alternations between these extremes intensifies the effect. The page looks shredded in Safaris reader mode, so that's no help either.
Re: The Simplicity of Prolog
#126Am I the only who finds this article to be inaccessible due to color choices and implementation? I'm really interested in Prolog, but my eyes feel the strain after a few sentences. The reason is that the contrast ratio of some parts is very low, of others excessively high. The constant alternations between these extremes intensifies the effect. The page looks shredded in Safaris reader mode, so that's no help either.
It's not just you: Its typography and design is quite unsuitable to reading. The lines are too long, there is not enough leading, the typeface is badly chosen, and the black blocks everywhere are unpleasant and off putting.
Re: The Simplicity of Prolog
#127Earlier quoted context omitted.
I think there is some confusion around what is "first class" in Prolog. Any syntactically valid construct in (ISO-conforming) Prolog is "first class", including the symbols that are the names of predicates. The fact that Prolog is a homoiconic language makes any valid Prolog code "first class". "First class" meaning, can be the arguments to a predicate or processed as data. Predicates (and only predicates) can be cal…
> Any syntactically valid construct in (ISO-conforming) Prolog is "first class" First class data, yes. First class predicate, no. > Predicates (and only predicates) can be called with `call/N` Some class of things that you apparently refuse to call "predicates" can also be called, but without having to use call/N. > Perhaps you mean, [...] No. I mean there are first-class callable things and second-class callable thi…
However, this is a charitable interpretation that is open to abuse if desired.
It is starting to sound like the criticism is that Prolog is not an object oriented programming language and does not pass contextual object information along with symbols in the same way SICP-style higher order functions are treated in functional programming languages.
This is by design, Prolog is a logic language that describes relationships, not a procedural language.
There is no behavioral difference that distinguishes a Prolog predicate as not "first class". There are many metapredicates designed to accept predicates as arguments, such as maplist/N. This is the primary criteria for supporting first class "callables" (another word poorly suited for Prolog, but I'm admitting it for purposes of conversation) in other languages. I would have assumed that would be a sufficient behavioral affordance.
> there are first-class callable things and second-class callable things
To make this more concrete, please provide some examples of "first-class" and "second-class" "callable things" in Prolog, as well as an example of "first class" and "second class" "callable things" in another language.
Given your level of confidence in your argument, I assume this should be fairly easy to do. Then we might have a concrete basis for discussion.
Re: The Simplicity of Prolog
#128Earlier quoted context omitted.
> Any syntactically valid construct in (ISO-conforming) Prolog is "first class" First class data, yes. First class predicate, no. > Predicates (and only predicates) can be called with `call/N` Some class of things that you apparently refuse to call "predicates" can also be called, but without having to use call/N. > Perhaps you mean, [...] No. I mean there are first-class callable things and second-class callable thi…
First of all lets be clear: the concepts of "first class" and "callable" are procedural terminology coming from object oriented and functional languages. I am admitting them to the discussion for purposes of comparative language analysis. My criteria is "if a reasonable person would recognize a language construct in Prolog as similar to an equivalent language construct in an OO or FP language, we can discuss it as if…
Not for you, but purely for the benefit of unfortunate souls who wander by and are confused what there is to argue about:
call_direct_and_indirect(IndirectCallTarget, Input, Result) :-
call_direct(Input, Intermediate), % first-class call
call(IndirectCallTarget, Intermediate, Result). % second-class call
This predicate calls some other predicate `call_direct/2` in a first-class way. It's a call.It also calls some predicate identified by whatever the variable IndirectCallTarget may be bound to. This is a second-class call. It's frequently referred to as a "meta-call" to signal that it's not a first-class call. It's important to note that the value passed in for the IndirectCallTarget parameter is not a predicate. It cannot be, since there are no predicate values in Prolog. It's the name of a predicate. (Plus maybe a partial argument list; still not a predicate.) Since the thing being meta-called is not a predicate, it must be meta-called specially using the `call/N` builtin. The user has no realistic way of implementing the `call/N` builtin themselves.
Re: The Simplicity of Prolog
#129Earlier quoted context omitted.
First of all lets be clear: the concepts of "first class" and "callable" are procedural terminology coming from object oriented and functional languages. I am admitting them to the discussion for purposes of comparative language analysis. My criteria is "if a reasonable person would recognize a language construct in Prolog as similar to an equivalent language construct in an OO or FP language, we can discuss it as if…
I really don't care what you "admit". Now you're saying that it doesn't matter whether Prolog has predicates as first-class values, and yet you keep arguing that it does have them. I don't think you're here anymore to establish what statements about Prolog are true or false. You're here for a fight; I'm not here for a fight. Go fight yourself. Not for you, but purely for the benefit of unfortunate souls who wander by…
> call_direct_and_indirect(IndirectCallTarget, Input, Result) :- call_direct(Input, Intermediate), % first-class call call(IndirectCallTarget, Intermediate, Result). % second-class call
I see we are at an unfortunate impasse. I assert what you are calling a "second-class call" is usually considered "first-class". I will leave the definition here for readers to decide for themselves. I rest my case and wish you a good day.
https://en.wikipedia.org/wiki/First-class_function
> Higher-order functions: passing functions as arguments
Further information: Higher-order function
In languages where functions are first-class citizens, functions can be passed
as arguments to other functions in the same way as other values (a function
taking another function as argument is called a higher-order function). In the
language Haskell:
map :: (a -> b) -> [a] -> [b]
map f [] = []
map f (x:xs) = f x : map f xsRe: The Simplicity of Prolog
#130Earlier quoted context omitted.
First of all lets be clear: the concepts of "first class" and "callable" are procedural terminology coming from object oriented and functional languages. I am admitting them to the discussion for purposes of comparative language analysis. My criteria is "if a reasonable person would recognize a language construct in Prolog as similar to an equivalent language construct in an OO or FP language, we can discuss it as if…
I really don't care what you "admit". Now you're saying that it doesn't matter whether Prolog has predicates as first-class values, and yet you keep arguing that it does have them. I don't think you're here anymore to establish what statements about Prolog are true or false. You're here for a fight; I'm not here for a fight. Go fight yourself. Not for you, but purely for the benefit of unfortunate souls who wander by…
Not sure what you mean by realistic, but `call/1` can be implemented by having one simple rule for each existing predicate (now for the sake of the argument ignoring control constructs, which require somewhat more complex processing first) plus a rule for uninstantiated variables and one for an inexistant predicate. And `call/N, N > 1` can now be defined based on it.