Hi!

I'm using Language::Prolog::Yaswi.

Everything works ok with 'consult'ing prolog files.

When I write all my prolog in modules (without public/export
declaration) I have problems to use them in L::P::Yaswi.

My mini example (see attachments) has a predicate give_me_sth/2, that
can be used this way in pure swi prolog:

    $ pl
    ?- use_module('a.swipl').
    ?- use_module('b.swipl').
    ?- module(a).
    a:  ?- give_me_sth(2, Answer).
    Answer = 222 ;
    a:  ?- module(b).
    b:  ?- give_me_sth(2, Answer).
    Answer = 2 ;

However I'm not able to call it from Perl with L::P::Yaswi. I always
get:    error(existence_error(procedure, '/'(give_me_sth, 2)), _100).

I thought it should basically used this way:

  swi_use_modules ( "./a.swipl", "./b.swipl" );
  local $swi_module = 'a';                         ### or 'b'
  swi_set_query( give_me_sth(2, Answer) );
  swi_var(Answer);

Please see attachment for full mini example.

If someoene please could give me a hint what I'm doing wrong ...

I'm no prolog wizard anyway, so it's also possible I'm doing
something wrong there. 

(Greeti+Tha)nX
Steffen 
-- 
Steffen Schwigon <[EMAIL PROTECTED]>
Dresden Perl Mongers <http://dresden-pm.org/>
#! /usr/bin/perl

use strict;
use warnings;

use Language::Prolog::Types::overload;
use Language::Prolog::Yaswi qw(:query :load :context);
use Language::Prolog::Sugar
 functors => { give_me_sth => 'give_me_sth' },
 vars     => [qw( Answer )] ;

swi_use_modules ( "./a.swipl", "./b.swipl" );

sub yaswi_give_me_sth {
  local $swi_module     = 'a';     ### or 'b'

  # Variante 1
  swi_set_query( give_me_sth(2, Answer) );
  my $answer = swi_var(Answer) if swi_next;
  swi_cut if swi_next;
  print "Answer: $answer \n";
}

yaswi_give_me_sth();

Attachment: a.swipl
Description: Binary data

Attachment: b.swipl
Description: Binary data

Reply via email to