Re: foreign predicate not working (one more observation)

Paulo Moura <[email protected]>
Newsgroups gmane.comp.gnu.prolog.general
Message-ID <[email protected]>
On 19/jul/2004, at 15:25, Saurabh Bhatla wrote:

> :- foreign(get_event_ob(+string,-string)).
>
> :-object(receiver).
>
> 	:-public(receive/1).
> 	:-public(validate/1).
> 	:-public(get_event_ob/2).
> 	
> 	receive(Event).
>
> 	validate(Event):-
> 		self(Self),
> 		Self::get_event_ob(Event,Object),
> 		write(Object),	
> 		write('<-object found for event->'),
> 		write(Event),nl.
>
> 	validate(Event):-
> 		write('No object found for event->'),
> 		write(Event),nl.
> 		
>
> :-end_object.

Note that, because get_event_ob/2 is _declared_ as a _public predicate_ 
inside the object receiver, calls such as the following one:

> 		Self::get_event_ob(Event,Object),

always fail without error as get_event_ob/2 is within the scope of 
Self. Being a static predicate with no clauses, means that the calls to 
it always fail (you could be declaring a predicate which would only be 
defined in descendant objects).

Cheers,

Paulo


-----------------------------------------------------------
Paulo Jorge Lopes de Moura
Dep. of Informatics                   Office 4.3  Ext. 3257
University of Beira Interior          Phone: +351 275319700
6201-001 Covilhã                      Fax:   +351 275319891
Portugal

<mailto:[email protected]>
<http://www.di.ubi.pt/~pmoura>     <http://www.logtalk.org>
-----------------------------------------------------------
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.