Skip Menu |

This queue is for tickets about the AI-Prolog CPAN distribution.

Report information
The Basics
Id: 21447
Status: resolved
Priority: 0/
Queue: AI-Prolog

People
Owner: ovid [...] cpan.org
Requestors: agentzh [...] gmail.com
Cc:
AdminCc:

Bug Information
Severity: Normal
Broken in: 0.735_01
Fixed in: 0.741



Subject: AI::Prolog returns unblessed result objects
Here's the screenshot and the sample code used was copied from AI::Prolog's documentation. It's interesting to see there's no corresponding test in your test suite since all tests are passing on my macine. D:\projects\Pugs2>perl test.pl Can't call method "X" on unblessed reference at test.pl line 7. D:\projects\Pugs2>type test.pl use AI::Prolog; use Data::Dumper; my $prolog = AI::Prolog->new(append_prog()); $prolog->query("append(X,Y,[a,b,c,d])"); while (my $result = $prolog->results) { print Dumper($result->X); # array references #print Dumper($result->{X}); } sub append_prog { return <<' END_PROLOG'; append([], X, X). append([W|X],Y,[W|Z]) :- append(X,Y,Z). END_PROLOG }
From: OVID [...] cpan.org
On Tue Sep 12 10:34:37 2006, AGENT wrote: Show quoted text
> Here's the screenshot and the sample code used was copied from > AI::Prolog's documentation. It's interesting to see there's no > corresponding test in your test suite since all tests are passing on my > macine. > > D:\projects\Pugs2>perl test.pl > Can't call method "X" on unblessed reference at test.pl line 7. > > D:\projects\Pugs2>type test.pl > use AI::Prolog; > use Data::Dumper; > > my $prolog = AI::Prolog->new(append_prog()); > $prolog->query("append(X,Y,[a,b,c,d])"); > while (my $result = $prolog->results) { > print Dumper($result->X); # array references > #print Dumper($result->{X}); > } > > sub append_prog { > return <<' END_PROLOG'; > append([], X, X). > append([W|X],Y,[W|Z]) :- append(X,Y,Z). > END_PROLOG > }
This is a bug in the documentation, not the code. If you read http://search.cpan.org/dist/AI-Prolog/lib/AI/Prolog.pm#results, you'll see that in order to get object results back, you need to set raw_results() to false. Unfortunately, there was a deep bug in this which I never resolved, so I marked the feature as experimental and never followed up on it. However, it's clear that I need to update the documentation to reflect this. Thanks for bringing this to my attention. Cheers, Ovid
Fixed docs.