NAME
Language::XSB::Converter - Converts from Perl objects to Prolog terms
SYNOPSIS
package MyModule;
use Language::XSB::Converter;
our @ISA=qw(Language::XSB::Converter);
sub hash2prolog {
...
}
sub scalar2prolog {
...
}
etc.
ABSTRACT
This module implements functions used internally by Language::XSB::Base to convert from Perl objects and references to Prolog terms.
DESCRIPTION
You should only use this module if you want to change the default conversions performed when passing data between Perl and Prolog.
To override the default conversions, you have to create a new class with the method perl_ref2prolog
and set $Language::XSB::Base::converter
to one instance of your class.
If you make your converter class inherit Language::XSB::Converter, you can change conversions only for selected types overriding those methods:
$conv->hash2prolog($hash_ref)
-
converts a Perl hash reference to a Prolog term.
It creates a list of functors '=>/2' with the key/value pairs as arguments:
[ '=>'(key0, value0), '=>'(key1, value1), ... ]
$conv->scalar2prolog($scalar_ref)
-
converts a Perl scalar reference to a Prolog term.
$conv->glob2prolog($glob_ref)
-
converts a Perl glob reference to a Prolog term.
$conv->code2prolog($code_ref)
-
converts a Perl sub reference to a Prolog term.
$conv->object2prolog($object_ref)
-
converts any other Perl object to a Prolog term.
Default implementation looks for a method called
convert2prolog_term
in the object class.If this fails, it reverts to dump the internal representation of the object as the functor:
perl_object(class, state)
state
is the conversion of the perl datatype used to represent the object (array, hash, scalar, glob or sub).
EXPORT
None by default. This module has an OO interface.
SEE ALSO
Language::XSB::Base, Language::Prolog::Types
AUTHOR
Salvador Fandiño, <sfandino@yahoo.com>
COPYRIGHT AND LICENSE
Copyright 2002 by Salvador Fandiño
This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
1 POD Error
The following errors were encountered while parsing the POD:
- Around line 159:
Non-ASCII character seen before =encoding in 'Fandiño,'. Assuming CP1252