Newsgroups: comp.lang.scheme
Path: cantaloupe.srv.cs.cmu.edu!bb3.andrew.cmu.edu!newsfeed.pitt.edu!newsflash.concordia.ca!sunqbc.risq.net!news1.bellglobal.com!news.sprintlink.net!news-pen-14.sprintlink.net!www.nntp.primenet.com!nntp.primenet.com!news.sprintlink.net!news-peer.sprintlink.net!nntp-hub2.barrnet.net!venus.sun.com!wnoc-sfc-news!kogwy!math-keio!mad
From: mad@math.keio.ac.jp (MAEDA Atusi/=?ISO-2022-JP?B?GyRCQTBFREZYO0obKEI=?=)
Subject: Re: scheme vs prolog
In-Reply-To: ok@goanna.cs.rmit.edu.au's message of 31 Oct 1996 19:54:52 +1100
Content-Type: text/plain; charset=US-ASCII
Message-ID: <MAD.96Nov5155504@tanzanite.math.keio.ac.jp>
Sender: news@math.keio.ac.jp
Nntp-Posting-Host: tanzanite
Reply-To: mad@math.keio.ac.jp
Organization: Faculty of Sci. and Tech., Keio Univ., Yokohama, Japan.
References: <327663E8.52C5@visi.com> <MAD.96Oct31111853@tanzanite.math.keio.ac.jp>
	<559pgs$h02$1@goanna.cs.rmit.edu.au>
Mime-Version: 1.0 (generated by tm-edit 7.66)
Date: Tue, 5 Nov 1996 06:55:04 GMT
Lines: 99


In article <559pgs$h02$1@goanna.cs.rmit.edu.au> ok@goanna.cs.rmit.edu.au (Richard A. O'Keefe) writes:

    > mad@math.keio.ac.jp (MAEDA Atusi/=?ISO-2022-JP?B?GyRCQTBFREZYO0obKEI=?=) writes:
    >> When I write programs in prolog and prolog-like languages, I spend
    >> most of my time avoiding unwanted non-determinism and backtracking
    >> (i.e. inserting cut operators here and there).

    > Cut is not an operator, and that is not the method that good Prolog
    > programmers use for controlling nondeterminism.

I'm not sure but some people use this terminology.  E.g.  "Concurrent
Prolog: Collected Papers" (Ehud Shapiro ed., MIT Press, 1987) has
index entry for "cut operator", not "cut".

    >> Prolog's `backtrack by default' behavior is pain because I need simple
    >> loop or simple if-then construct far more frequently than brute-force
    >> exhaustive search.

    > If you want a simple if-then-else, the language offers one, with syntax
    > straight out of the Lisp 1.5 manual:

    > 	( Test1 -> Do_If_Test1_True
    > 	; ...
    > 	; Testn -> Do_If_Testn_True
    > 	;          Do_If_All_Tests_False
    > 	)

What's the essential difference with this and

    Head1 :- !, Do_If_Test1_True.
    ...
    Headn :- !, Do_If_Testn_True.
    HeadElse :- Do_If_All_Tests_False.

in top level?  I use both of them.

    > Simple loops are coded in Prolog exactly the same way they are in 
    > other pattern-matching languages (without backtracking) like ML:

    > 	append([], L, L).
    > 	append([H|T], L, [H|R]) :-
    > 	    append(T, L, R).

    > is as deterministic (when the first argument is known) as you could
    > possibly wish for.  No cuts are needed.

Hmmm.

    intersection([H|T], L, [H|R]) :- member(X, L), !, intersection(T, L, R).
    intersection([_|T], L, R) :- intersection(T, L, R).
    intersection([], _, []).

Is the above code so weired?  Please correct me if it's so bad.

    >> I would like prolog if it had made backtracking optional and made
    >> deterministic call the default.

    > In short, you would like Prolog if it wasn't a *logic* programming
    > language.  Backtracking is not some sort of optional extra in Prolog;
    > something of the sort is _required_ by the semantics.

Not necessarily.  Many concurrent logic programming languages has no
notion of sequential backtracking.

    >> I'd rather use KL1, a parallel logic
    >> programming language which doesn't have backtracking.  KL1 and other
    >> commited-choice languages have much cleaner semantics, too.

    > I haven't seen the semantics of KL1; would you care to post a reference?

KL1 is based on flat-GHC and GHC family languages are described in
"The Family of Concurrent Logic Programming Languages", Ehud Shapiro,
ACM Computing Surveys 21(4): 629 (1989).

    > I guarantee you that KL1 hasn't got a cleaner semantics than Mercury,
    > which is very Prolog-like except it is both *more* logical and *more*
    > efficient.  It would almost be fair to say
    > 	Mercury:Prolog :: ML:Scheme.

Looks like a good flame bait for comp.lang.scheme :-).  Seriously, I
feel KL1 (and other committed choice languages) `clean'
w.r.t. treatment of cuts.  In KL1, exactly one cut (`commit operator') 
is *required* for every clause.

    > If you want a basically deterministic single-solution language with a
    > little bit of backtracking exactly where you want it, then don't whinge
    > about how Prolog wasn't designed for your taste, use something that _was_.
    > Jeff Siskind's "Screamer" package is freely available, and extends Lisp
    > in what sounds like *exactly* the way you want.

Of course I choose language that I prefer whenever possible.  And of
course I won't break into Prolog newsgroup and preach about how I
dislike Prolog.

I thought the original author wanted to hear a view of Prolog from
Lisp programmer.  And I just presented mine.

					--mad
