Language::Prolog::Types::Converter - Converts from Perl objects to Prolog terms
package MyModule; use Language::Prolog::Types::Converter; our @ISA=qw(Language::Prolog::Types::Converter); sub hash2prolog { ... } sub scalar2prolog { ... } etc.
This module implements a class to be used from interfaces to Prolog systems (SWI-Prolog, XSB, etc.) to transform complex Perl data types to Prolog types.
You should use this module if you want to change the default conversions performed when passing data between Perl and Prolog.
Language::Prolog::Types::Converter-
returns a new converter object.
$self->pass_as_opaque($class1, $class2, ...)
instruct the converter object to pass objects belonging to classes class1, class2, etc. to Prolog as opaque objects. The Prolog interpreter will not touch them but just use them in Perl call backs.
To override the default conversions performed, you have to redefine the method perl_ref2prolog.
perl_ref2prolog
If you make your converter class inherit Language::Prolog::Types::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.
convert2prolog_term
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).
state
None by default. This module has an OO interface.
Language::Prolog::Types, Language::XSB::Base, Language::Prolog::Yaswi::Low.
Salvador Fandiño, <sfandino@yahoo.com>
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:
Non-ASCII character seen before =encoding in 'Fandiño,'. Assuming CP1252
To install Language::Prolog::Types, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Language::Prolog::Types
CPAN shell
perl -MCPAN -e shell install Language::Prolog::Types
For more information on module installation, please visit the detailed CPAN module installation guide.