Slash Boxes
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

use Perl Log In

Log In

[ Create a new account ]

Journal of jjore (6662)

Friday July 28, 2006
01:57 AM

AI::Prolog calls back into perl

[ #30456 ]

I just patched my copy of AI::Prolog to allow calls back into arbitrary perl code. The following prolog query works just like you'd expect the complementary perl code to operate. I think that perlcall2/2 should succeed if it can call the function and fail if it can't. There oughta be a related perlcall/2 which is implemented by preventing backtracking through the function. Probably for convenience there oughta be some kind of interpolation of perl variables into strings. Probably also some predicates with arity 1 for a simple case when there's no arguments. Uh... other goo to make things simple. Whatever. This is just a primitive. I suppose there oughta be a method calling primitive too.

% In prolog...
perlcall2( "my_function", [ "my", "args" ] ).

# In perl...
my_function( 'my', 'args' )

This is so Mapping URLs to code with Prolog could possibly work. The diff against AI-Prolog-0.734 is at It suffers from just searching upwards in the call stack to find the function so it could find the wrong thing.

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
More | Login | Reply
Loading... please wait.