PROLOG-REQUEST@SUSHI.STANFORD.EDU (Chuck Restivo, The Moderator) (01/03/88)
PROLOG Digest Monday, 4 Jan 1988 Volume 6 : Issue 2
Today's Topics:
Query - get0/read & Call,
LP Library - Book
----------------------------------------------------------------------
Date: 30 Dec 87 14:20:58 GMT
From: cos!duc@uunet.uu.net (Duc Kim Nguyen)
Subject: Question on get0/read and call
I have a question concerning get0/read and call (I am using Quintus Prolog):
(1) A predicate f is defined with
:- op(700,fx,f).
(2) A prompt requests input from the terminal:
a) when I use read/1 to get input, eg. f tata, and call/1 on the
input, the call takes place, ie., execution of predicate f occurs
with input tata;
b) when I decided to use the prompt library which uses a loop of get0/1
to build up a list of input, and used atom_chars to convert list
into atom, the call/1 on this term `f tata' resulted in prediciate
'f data' undefined.
Can someone explain to me what the difference between these two cases ?
It seemed the blank made a difference in the two cases ?
------------------------------
Date: 31 Dec 87 12:56:51 GMT
From: linc.cis.upenn.edu!lang@super.upenn.edu (Francois-Michel Lang)
Subject: Question on get0/read and call
I'm not sure I fully understand the question/problem, but I think I
can clear up one apparent misconception: The operator declaration
:- op(700,fx,f).
does NOT define a predicate. It only allows you to use the atom 'f'
as a prefix operator. That sounds like it's part of the problem.
-- Francois-Michel Lang
------------------------------
Date: 31 Dec 87 01:53:00 GMT
From: quintus!ok@sun.com (Richard A. O'Keefe)
Subject: Question on get0/read and call
I'm afraid I don't understand your question. I'll answer what I
*think* is the question you are asking.
(1) An operator declaration doesn't define a predicate.
The operator declaration has nothing to do with what I *think*
your problem is.
(2) As near as I can figure out, you are trying two things.
| ?- read(Goal), call(Goal).
|: f data.
This is the one that works.
| ?- ensure_loaded(library(prompt)),
| prompted_line('Enter goal: ', Chars),
| atom_chars(Atom, Chars),
| call(Atom).
Enter goal: f data
This is the one that doesn't work.
The blank has nothing to do with anything at all.
The answer is this:
The built-in predicate read/1 reads a ***TERM***.
In this particular example, the term you read was f(data).
That is, it is a compound term with principal function symbol 'f'
and arity 1, whose single argument is the atom 'data'.
So in the example that works, you are doing call(f(data)).
The library predicate prompted_line/2 reads a list of character
codes. In this particular example, the list was "f data".
The built-in predicate atom_chars(Atom, Chars) expresses the
relation between an ***ATOM*** and the list of characters
comprising the name of the atom. In this particular example,
the atom you got back was 'f data'.
So in the example that doesn't work, you are doing call('f data').
That is, you are trying to call a predicate whose predicate
symbol is 'f data' and which has no arguments. If you had said
"f(data)" instead of "f data", you would have ended up trying to
call a predicate of no arguments whose name was the atom 'f(data)'.
You should have got an error message which looked like this:
[Warning: The procedure 'f data'/0 is undefined]
(1) 1 Call: 'f data' ?
DO pay attention to the single quotes in the error message,
they ARE telling you something!
There are at least two ways of doing what you apparently want.
(a) prompt_and_read(Prompt, Term) :-
prompt(Prompt),
read(Term).
This version requires you to terminate the input term with a full
stop and layout character, as always when using read/1.
(b) :- ensure_loaded(library(charsio)).
prompted_term(Prompt, Term) :-
prompted_line(Prompt, Chars),
chars_to_term(Chars, Term).
This version doesn't require you to terminate the input with a
full stop and layout character, but it won't let you use more
than one line for the term either.
On the grounds of portability, efficiency, and general hygiene,
I'd go for (a).
------------------------------
Date: Thu, 31 Dec 87 9:52:44 PST
From: Kahn.pa@Xerox.COM
Subject: Concurrent Prolog Book Announcement
CONCURRENT PROLOG
COLLECTED PAPERS
(2 Vols.)
Edited by Ehud Shapiro
MIT Press Series in Logic Programming
ISBN 0-262-19266-7 (vol. 1) (pp. 560)
ISBN 0-262-19257-5 (vol. 2) (pp. 680)
ISBN 0-262-19255-1 (two volume set)
Table of Contents
Volume 1
The Authors ix
The Papers xv
Foreword xix
Preface xxi
Introduction xxv
Part I: Concurrent Logic Programming Languages 1
Introduction 2
1. A Relational Language for Parallel Programming 9
K. Clark and S. Gregory
2. A Subset of Concurrent Prolog and Its Interpreter 27
E. Shapiro
3. PARLOG: Parallel Programming in Logic 84
K. Clark and S. Gregory
4. Guarded Horn Clauses 140
K. Ueda
5. Concurrent Prolog: A Progress Report 157
E. Shapiro
6. Parallel Logic Programming Languages 188
A. Takeuchi and K. Furukawa
Part II: Programming Parallel Algorithms 203
Introduction 204
7. Systolic Programming: A Paradigm of Parallel Processing 207
E. Shapiro
8. Notes on the Complexity of Systolic Programs 243
S. Taylor, L. Hellerstein, S. Safra and E. Shapiro
9. Implementing Parallel Algorithms in Concurrent Prolog: The
Maxflow Experience 258
L. Hellerstein and E. Shapiro
10. A Concurrent Prolog Based Region Finding Algorithm 291
L. Hellerstein
11. Distributed Programming in Concurrent Prolog 318
A. Shafrir and E. Shapiro
12. Image Processing with Concurrent Prolog 339
S. Edelman and E. Shapiro
13. A Test for the Adequacy of a Language for an Architecture 370
E. Shapiro
Part III: Streams and Channels 389
Introduction 390
14. Fair, Biased, and Self-Balancing Merge Operators: Their
Specification and Implementation in Concurrent Prolog 392
E. Shapiro and C. Mierowsky
15. Multiway Merge with Constant Delay in Concurrent Prolog 414
E. Shapiro and S. Safra
16. Merging Many Streams Efficiently: The Importance of Atomic
Commitment 421
V.A. Saraswat
17. Channels: A Generalization of Streams 446
E.D. Tribble, M.S. Miller, K. Kahn, D.G. Bobrow, C. Abbott and
E. Shapiro
18. Bounded Buffer Communication in Concurrent Prolog 464
A. Takeuchi and K. Furukawa
References 477
Index 507
Volume 2
The Authors ix
The Papers xiii
Preface to Volume 2 xvii
Part IV: Systems Programming 1
Introduction 2
19. Systems Programming in Concurrent Prolog 6
E. Shapiro
20. Computation Control and Protection in the Logix System 28
M. Hirsch, W. Silverman and E. Shapiro
21. The Logix System User Manual, Version 1.21 46
W. Silverman, M. Hirsch, A. Houri and E. Shapiro
22. A Layered Method for Process and Code Mapping 78
S. Taylor, E. Av-Ron and E. Shapiro
23. An Architecture of a Distributed Window System and its FCP
Implementation 101
D. Katzenellenbogen, S. Cohen and E. Shapiro
24. Logical Secrets 140
M.S. Miller, D.G. Bobrow, E.D. Tribble and J. Levy
Part V: Program Analysis and Transformation 163
Introduction 164
25. Meta Interpreters for Real 166
S. Safra and E. Shapiro
26. Algorithmic Debugging of GHC Programs and Its Implementation
in GHC 180
A. Takeuchi
27. Representation and Enumeration of Flat Concurrent Prolog
Computations 197
Y. Lichtenstein, M. Codish and E. Shapiro
28. A Type System for Logic Programs 211
E. Yardeni and E. Shapiro
Part VI: Embedded Languages 245
Introduction 246
29. Object Oriented Programming in Concurrent Prolog 251
E. Shapiro and A. Takeuchi
30. Vulcan: Logical Concurrent Objects 274
K. Kahn, E.D. Tribble, M.S. Miller and D.G. Bobrow
31. PRESSing for Parallelism: A Prolog Program Made Concurrent 304
L. Sterling and M. Codish
32. Compiling Or-Parallelism into And-Parallelism 351
M. Codish and E. Shapiro
33. Translation of Safe GHC and Safe Concurrent Prolog to FCP 383
J. Levy and E. Shapiro
34. Or-Parallel Prolog in Flat Concurrent Prolog 415
E. Shapiro
35. CFL --- A Concurrent Functional Language Embedded in a Concurrent
Logic Programming Environment 442
J. Levy and E. Shapiro
36. Hardware Description and Simulation Using Concurrent Prolog 470
D. Weinbaum and E. Shapiro
Part VII: Implementations 491
Introduction 492
37. A Sequential Implementation of Concurrent Prolog Based on the
Shallow Binding Scheme 496
T. Miyazaki, A. Takeuchi and T. Chikayama
38. A Sequential Abstract Machine for Flat Concurrent Prolog 513
A. Houri and E. Shapiro
39. A Parallel Implementation of Flat Concurrent Prolog 575
S. Taylor, S. Safra and E. Shapiro
References 605
Index 635
------------------------------
End of PROLOG Digest
********************