Languag...nverter(3)
π Language::Prolog::Types::Converter β the glow-up edition π
okay bestie, so this is a page from the User Contributed Perl Documentation, manual section 3, and it's all about Language::Prolog::Types::Converter. pull up a chair, we're converting Perl stuff into Prolog stuff and it's gonna be cute π
β¨ NAME β¨
Language::Prolog::Types::Converter β converts from Perl objects to Prolog terms. literally its whole personality π¦
πΈ SYNOPSIS πΈ
here's the vibe, copy it exactly bestie:
package MyModule;
use Language::Prolog::Types::Converter;
our @ISA=qw(Language::Prolog::Types::Converter);
sub hash2prolog {
...
}
sub scalar2prolog {
...
}
etc.
π ABSTRACT π
so this module implements a class that you use from interfaces to Prolog systems (SWI-Prolog, XSB, etc.) to transform complex Perl data types into Prolog types. it's the little translator bestie that makes the two of them get along π«Ά
π DESCRIPTION π
you should use this module if you want to change the default conversions performed when passing data between Perl and Prolog. that's the assignment, periodt β¨
π§ METHODS π§
Language::Prolog::Types::Converter->new()β returns a new converter object. brand new, fresh out the box, main character energy π$self->pass_as_opaque($class1, $class2, ...)β instructs the converter object to pass objects belonging to classes class1, class2, etc. to Prolog as opaque objects. the Prolog interpreter will not touch them, it just uses them in Perl call backs. hands off, she's not yours π
so to override the default conversions performed, you have to redefine the method perl_ref2prolog.
and if you make your converter class inherit Language::Prolog::Types::Converter, you can change conversions only for selected types by overriding these 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.
the default implementation looks for a method called convert2prolog_term in the object class. π
if this fails, it reverts to dumping 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). so yeah, plan B is literally just "show them the insides" π iconic honestly
π EXPORT π
none by default. this module has an OO interface. no sneaky exports, she does not do that π
β SEE ALSO β
Language::Prolog::TypesLanguage::XSB::BaseLanguage::Prolog::Yaswi::Low
go read those too, iykyk π₯
π 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. π«Ά
π POD ERRORS π
hey! the above document had some coding errors, which are explained below:
around line 210:
Non-ASCII character seen before =encoding in 'FandiΓ±o,'. Assuming
CP1252
not the Γ± catching strays π bestie the encoding said what it said
and that's the whole page, no cap π this was perl v5.42.0, dated 2025-07-25, straight from Languag...nverter(3) β mwah, slay, go convert some stuff β¨π
π¦
π¦ where this page comes from
- fedora 43: perl-Language-Prolog-Types 0.10-38.fc43 Β· GPL-1.0-or-later OR Artistic-1.0-Perl
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms