[Date Prev] [Date Next] [Thread Prev] [Thread Next] Date Index Thread Index Search archive:
Date:Mon Mar 3 10:33:38 1994 
Subject:Re: clause/2 in Poplog Prolog 
From:Tom Khabaza 
Volume-ID:940303.01 

Hello Edmund,
Adrian is right - clause/2 is not supposed to work with it's first
argument uninstantiated.  Bratko agrees, and I'm sure C&M would also
but haven't got one to hand.

The simplest way to do what you want in Poplog Prolog (and various other
Prologs) is to use current_predicate/2, as in:

    married(charles, diana).
    separated(charles, diana).

    relations(R, charles, diana) :-
        current_predicate(R, X),
        clause(X, true),
        X =.. [R, charles, diana].

    ?- relations(R,C,D).
    R = separated
    C = charles
    D = diana ? ;

    R = married
    C = charles
    D = diana ? ;

    no

Just out of interest, which Prologs allow clause/2 with an
uninstantiated first argument?  This is rather naughty since most
textbooks will say it's illegal.
tom