[Date Prev] [Date Next] [Thread Prev] [Thread Next] Date Index Thread Index Search archive:
Date:23 Oct 2004 14:17:07 -0000 
Subject:help request: Use of pop11 database facilities 
From:Aaron Sloman 
Volume-ID: 

Wayn wrote:

> Setpop
> : load 'mybot.p'
>
>
> ;;; LOADING mybot.p
> ;;; LOADING mydatabase.p
> ;;; DECLARING VARIABLE verify
> ;;; DECLARING VARIABLE line
> : converse();
>
> ** [hello]
> ** [what is your name ?]
> ? doc
> ** [pleased to meet you doc]
> ** [well - what do you want to talk about ?]
> ? how are you?
>
> ;;; MISHAP - ATTEMPT TO ADD UNDER SPECIFIED ITEM
> ;;; INVOLVING:  [how are you ?]
> ;;; DOING    :  add converse pop_setpop_compiler

The pop11 database program, as described in TEACH DATABASE
allows things like:

    add([steve is a teacher]);

but does not allow lists containing question marks, e.g.

    add([is steve a teacher?]);

Note that pop11 will parse that as equivalent to

    add ( [ is steve a teacher ? ] ) ;

The procedure 'add' does not allow question marks in the list to be
added as they are used in pattern elements form the pattern matcher.
(See HELP MATCHES).

add also does not allow the following items in lists

    ?? = ==

because those are also pattern elements used by present, lookup,
etc. to search the database.

The check for such things helps prevent some student errors based on
confusion between adding things to the database and searching for things
in the database.

If you want to be able to add any list at all, you can ignore the
library version of add and define your own thus:

    vars database = [],  it;

    define add(X);
        X -> it;
        X :: database -> database;
    enddefine;

That will do no checking and you can add anything at all
to the database. If you wish to restrict it to adding lists
you can use something like:

    define add(X);
        if islist(X) then
            X -> it;
            X :: database -> database;
        else
            mishap('List needed by add', [^X]);
        endif
    enddefine;

=======================================================================

Another problem:

> ** [well - what do you want to talk about ?]
> ? hi
>
> ;;; MISHAP - LIST NEEDED
> ;;; INVOLVING:  <undef meaning>
> ;;; DOING    :  answer converse

This tells you that you have used a variable called
"meaning" in your procedure called 'answer', where the program
expected the value of "meaning" to be a list, but
when you ran the program it did not have the
right kind of value. In fact it was an undefined object, printed
as <undef meaning>

That most likely happened because somewhere you used

    [ ...     ^^meaning    ...]

in a procedure where you USED the variable "meaning" but did
not previously give a value to it.

Before you go any further, search for every occurrence of 'meaning' in
each of your procedures and check that a value has been assigned
to it before it is used. This can be done successfully
either

o because "meaning" is an input variable for the procedure

    define verify( thing, meaning)

or

o because it is given a value by a pop11 assignment

    .... -> meaning;

or

o because it is given a value by the pattern matcher using
    ?meaning
or

    ??meaning

for instance in:
        ....
    elseif present([...  ??meaning ...]) then
        ... [  ...  ^^meaining ...] ...

When you have found each occurrence of 'meaning' and made sure it
has a value before it is used (e.g. with ^ or ^^), then you
can test every such procedure separately from the rest of the program
to make sure it works for every kind of case for which you have designed
it.

Only after you have tested every procedure separately should
you try running the whole program. Otherwise debugging
is too hard.

I hope that helps

Aaron