Re: prolog natural language interface to unix

From: Joachim Schimpf <>
Date: Fri 10 Sep 1999 05:07:43 PM GMT
Message-ID: <>
ade wrote:
> [eclipse 11]: read_string(stdout, "\n",_,R).
> type error in read_string(stdout, [92, 110], _61, R)

Your problem is with the double quotes:

Unlike other Prologs, Eclipse has a special string data type.
By default, double-quoted items are such strings.

You seem to be using one of Eclipse's compatibility packages,
which change the meaning of the double-quotes to be the same
as in other Prologs, i.e. to denote lists of character codes:

[eclipse 1]: X = "abc".

X = "abc"                    <---- an eclipse-string
[eclipse 2]: lib(cprolog).   <---- for example

[eclipse 3]: X = "abc".

X = [97, 98, 99]             <----- a list of ascii codes

The read_string/4 built-in expects a proper string as its
second argument and makes an error when you give it a list.

Now you could start using string_list/2 to convert between the
two representations, but I wouldn't recommend that. The compatibility
packages are really intended for porting existing code - writing new
code that mixes Eclipse-specific features and compatibility features
should be avoided... (Note however that the effect of compatibility
packages is local to the module where they are loaded, i.e. you could
theoretically write part of your application in native Eclipse and
another part in some other Prolog dialect).

> Likewise if I use
>             exec('/usr/bin/find . -name filename -print',[in,out],P)
> with
>             read_string(out, "\n", _, Answer)
> I get

Here is a sample interface to the find-command in plain Eclipse
(no compatibility packages loaded):

find(FileName, List) :-
        concat_string(["/usr/bin/find . -name ",FileName," -print"],
        exec(Cmd, [null,Out]),
        output_to_list(Out, List).

    output_to_list(Out, List) :-
        ( read_string(Out, "\n", _, Line) ->
            List = [Line|More],
            output_to_list(Out, More)
            List = [],

[eclipse 2]: find("*.ps", Files).

Files = ["./", "./","./",

 Joachim Schimpf                /               phone: +44 171 594 8187
 IC-Parc, Imperial College     /    
 London SW7 2AZ, UK           /
Received on Fri Sep 10 18:14:04 1999

This archive was generated by hypermail 2.1.8 : Wed 16 Nov 2005 06:07:04 PM GMT GMT