Grokbase Groups Perl ai February 2005
FAQ
Hi,

I have uploaded to CPAN version 0.07 of Language::Prolog::Yaswi,
an interface to SWI-Prolog.

It fixes several bugs and includes some new commodity functions
to call prolog from perl (i.e. swi_inline or swi_parse).

This release requieres SWI-Prolog version 5.4.x. Versions on the
unstable branch (5.5.x) are not supported because unicode support
(main change between 5.4 and 5.5) has not been incorporated on
SWI-Prolog foreign interface yet.

I have also released DBD::Yaswi, an experimental DBI interface to
SWI-Prolog. I am not completely sure if this module is a real
improvement over the raw Language::Prolog::Yaswi... well,
comments are welcome!!!

Cheers,

- Salvador

Search Discussions

  • Ovid at Feb 22, 2005 at 5:05 pm

    --- Salvador Fandiño wrote:
    I have uploaded to CPAN version 0.07 of Language::Prolog::Yaswi,
    an interface to SWI-Prolog.

    I have also released DBD::Yaswi, an experimental DBI interface to
    SWI-Prolog. I am not completely sure if this module is a real
    improvement over the raw Language::Prolog::Yaswi... well,
    comments are welcome!!!
    Hi Salvador,

    It's great to see stuff happening with this again!

    When I first tried to isntall DBD::Yaswi, I got:

    ok 1 - use DBI;
    install_driver(Yaswi) failed: Can't locate DBD/Yaswi.pm
    in @INC (@INC contains:
    <snip>
    Perhaps the DBD::Yaswi perl module hasn't been fully
    installed, or perhaps the capitalisation of 'Yaswi' isn't
    right.
    Available drivers: DBM, ExampleP, File, Pg, Proxy, SQLite, Sponge.
    at t/1.t line 6

    I just did a force install to see what would happen and I reran the
    test:

    ok 1 - use DBI;
    install_driver(Yaswi) failed: syntax error at
    /usr/local/lib/perl5/site_perl/5.8.6/DBD/Yaswi.pm line 134,
    near "Vs qw(Q M N V B)"
    BEGIN not safe after errors--compilation aborted at
    /usr/local/lib/perl5/site_perl/5.8.6/DBD/Yaswi.pm line 194.
    Compilation failed in require at (eval 2) line 3.

    At line 134, deleting the "Vs" from it makes the DBD load:

    my @vs = Vs qw(Q M N V B);

    But a few lines later we get 'can''t call method "length" on unblessed
    reference':

    $sth->STORE(NUM_OF_PARAMS => $marks->length);

    That's when I stopped.

    Also, from the docs, it's not clear how to build a database or issue
    queries against it. So let's say I want to find all X and Y that
    satisfy append/3, would I do something like this?

    my $dbh = DBI->connect('dbi:Yaswi:user');
    my $sth = $dbh->prepare(<<'END_PROLOG');
    find [X,Y] where Z=[a,b,c,d], \
    append([],X,X). \
    append([W|X],Y,[W|Z]) :- append(X,Y,Z).
    END_PROLOG

    From your docs and the tests, that doesn't seem right.

    Can I load a pre-existing prolog program, call assert, retract, etc?

    As for the new Language::Prolog::Yaswi, it installed and ran just fine.
    I even had a little sample program of my own that seemed to work.
    Thanks!

    Now to see if it can run on OS X.

    Cheers,
    Ovid

    =====
    If this message is a response to a question on a mailing list, please send
    follow up questions to the list.

    Web Programming with Perl -- http://users.easystreet.com/ovid/cgi_course/
  • Salvador Fandiño at Feb 22, 2005 at 6:04 pm
    Hi,

    Ovid wrote:
    --- Salvador Fandiño wrote:
    I have uploaded to CPAN version 0.07 of Language::Prolog::Yaswi,
    an interface to SWI-Prolog.

    I have also released DBD::Yaswi, an experimental DBI interface to
    SWI-Prolog. I am not completely sure if this module is a real
    improvement over the raw Language::Prolog::Yaswi... well,
    comments are welcome!!!

    Hi Salvador,

    It's great to see stuff happening with this again!

    When I first tried to isntall DBD::Yaswi, I got:
    ...
    DBD::Yaswi has to be registered on the DBI module, Tim Bunce (the
    DBI author) have accepted to do it, but has not released a new
    DBI yet.

    You can modify your local DBI.pm:

    Look for the registry hash $dbd_prefix_registry definition and
    add an entry for DBD::Yaswi at the end as...

    yaswi_ => { class => 'DBD::Yaswi', },

    then it should work.


    Also, from the docs, it's not clear how to build a database or issue
    queries against it. So let's say I want to find all X and Y that
    satisfy append/3, would I do something like this?
    my $dbh = DBI->connect('dbi:Yaswi:user');
    my $sth = $dbh->prepare(<<'END_PROLOG');
    find [X,Y] where Z=[a,b,c,d], \
    append([],X,X). \
    append([W|X],Y,[W|Z]) :- append(X,Y,Z).
    END_PROLOG

    From your docs and the tests, that doesn't seem right.

    Can I load a pre-existing prolog program, call assert, retract, etc?

    You can freely mix calls to Language::Prolog::Yaswi and
    DBD::Query, the only requirement is to not let queries open from
    one module when calling the other (calling finish() on open
    DBD::Yaswi queries or swi_cut on the Language::Prolog::Yaswi side).

    There are new functions to consult files swi_consult() function
    to consult files, i.e:

    swi_consult qw(foo, bar)
    swi_use_modules qw(foo, bar)

    and the swi_inline function to consult inline modules.

    swi_inline <<PROLOG;
    append([], X, X).
    append([W|X],Y,[W|Z]) :- append(X,Y,Z).
    PROLOG


    DBD::Yaswi can be extended via the multifile predicate
    dbd:dbd_map_query/3.

    I have included support for two simple operations, "find" and
    "insert", just for experimentation, but others can be easyly
    added, for example "consult":

    $db=DBI->connect('dbi:Yaswi:user')

    # and then, always after the connect call to ensure that
    # DBD::Yaswi has been loaded (or alternatively, loading
    # DBD::Yaswi explicitly):

    swi_inline << PROLOG;
    dbd:dbd_map_query(consult(X), consult(X), []).
    PROLOG

    $db->do('consult(foo)')

    or even

    $sth_consult=$db->prepare('consult(?)')

    for (qw(foo bar doo) ) {
    $sth_consult->execute($_)
    }


    I know module documentation is poor, but I have not really made
    my mind yet about the right query language for DBD::Yaswi... and
    anyway, the code is available and it is also a good example of
    how to use Language::Prolog::Yaswi ;-)

    Cheers,

    - Salvador
  • Salvador Fandiño at Mar 16, 2005 at 1:06 pm
    Ovid and all,
    I have uploaded to CPAN version 0.07 of Language::Prolog::Yaswi,
    an interface to SWI-Prolog.

    I have also released DBD::Yaswi, an experimental DBI interface to
    SWI-Prolog. I am not completely sure if this module is a real
    improvement over the raw Language::Prolog::Yaswi... well,
    comments are welcome!!!

    Hi Salvador,

    It's great to see stuff happening with this again!

    When I first tried to isntall DBD::Yaswi, I got:
    Finally a new version of DBI, integrating support for DBD::Yaswi
    has been released.

    DBD::Yaswi should work out of the box, now.

    Cheers,

    - Salvador.

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupai @
categoriesperl
postedFeb 22, '05 at 4:16p
activeMar 16, '05 at 1:06p
posts4
users2
websiteperl.org

2 users in discussion

Salvador Fandiño: 3 posts Ovid: 1 post

People

Translate

site design / logo © 2021 Grokbase