[comp.lang.prolog] Backtracking for Happiness

jeff@aiai.ed.ac.uk (Jeff Dalton) (05/26/90)

In article <3044@goanna.cs.rmit.oz.au> ok@goanna.cs.rmit.oz.au (Richard A. O'Keefe) writes:
 >(b) You did realise that the preceding three rules are _Prolog_, didn't you?
 >    There's this little package that plugs into term_expansion/2.  (Well,
 >    two little packages:  I have one, Lee Naish has another better one.)

Yes, but the little packages probably don't cover all of ML.

 >(c) It might be clearer to express it as
 >	length(L) = scan_list(plus, map_list(k(1), L), 0).
 >    and have the definition in (a) generated automatically.
 >    (I assume that k(_, K) = K is already defined.)
 >
 >    Oh, which language do you think that definition's written in?

Oh, I don't know.  If we're allowed to use "little packages" maybe
it's Pascal.

ok@goanna.cs.rmit.oz.au (Richard A. O'Keefe) (05/26/90)

In article <2575@skye.ed.ac.uk>, jeff@aiai.ed.ac.uk (Jeff Dalton) writes:
: In article <3044@goanna.cs.rmit.oz.au> ok@goanna.cs.rmit.oz.au (Richard A. O'Keefe) writes:
:  >(b) You did realise that the preceding three rules are _Prolog_, didn't you?
:  >    There's this little package that plugs into term_expansion/2.  (Well,
:  >    two little packages:  I have one, Lee Naish has another better one.)

: Yes, but the little packages probably don't cover all of ML.

Neither they do.  Why should they?  Is ML the only functional language?
Alan Mycroft wrote the first version of the Mycroft/O'Keefe typechecker
in connection with his Hope->Prolog transliterator.  My package has 'let'
and 'where' for variables, and the only reason that it hasn't got nested
functions is that I've yet to run into a problem where I personally wanted
them.

:  >(c) It might be clearer to express it as
:  >	length(L) = scan_list(plus, map_list(k(1), L), 0).
:  >    and have the definition in (a) generated automatically.
:  >    (I assume that k(_, K) = K is already defined.)
:  >    Oh, which language do you think that definition's written in?

: Oh, I don't know.  If we're allowed to use "little packages" maybe
: it's Pascal.

When I say "a little package" I am talking about fewer than 300 lines
of Prolog code which plug into the term_expansion/2 hook so that a
user program can freely mix functional and clausal definitions in the
same file without using special commands.  In Lisp terms, top-level '='
is set up as a macro.  If one is allowed to use macros in Lisp without
it being thought that one is switching to a different language, then I
think a 300-line "macro" is fair enough for Prolog.

I mean to say, the "maybe it's Pascal" argument would justify someone
in replying to
    What language is this:  (setf (car x) y) ?
by saying
    Oh, I don't know.  Maybe it's Pascal.

I have a copy of T and use it nearly every day.  I have three free Schemes
which I used to use until I got T.  My two copies of CLtL (1st edition)
are rather worn; I keep looking in there for good ideas for Prolog.  I also
have a copy of SML of New Jersey, which was _supposed_ to work on Encores,
but doesn't.  Sigh.  You'll not catch _me_ knocking Lisp-like languages,
no, nor functional languages neither.  Spoil the Egyptians, that's what I say.
Let's face it, term_expansion/2 itself is an idea which owes much to Lisp.
The point is:  if you really want functional syntax in Prolog, you can _have_
it, and (due to some of the things Prolog has in common with Lisp) it isn't
hard.  If you want higher-order operations to be efficient, lean on your
vendor, they could be quite fast.

-- 
"A 7th class of programs, correct in every way, is believed to exist by a
few computer scientists.  However, no example could be found to include here."