1Language::Prolog::TypesU:s:eArbsCtornatcrti(b3u)ted PerlLaDnogcuuamgeen:t:aPtrioolnog::Types::Abstract(3)
2
3
4

NAME

6       Language::Prolog::Types::Abstract - Abstract classes for Prolog terms
7       in Perl.
8

SYNOPSIS

10         use Language::Prolog::Types::Abstract;
11         if prolog_is_atom('hello') {
12             print "'hello' is a Prolog atom\n"
13         }
14
15         ...
16
17         etc.
18

ABSTRACT

20       Language::Prolog::Types::Abstract defines a set of abstract classes for
21       Prolog terms.
22
23       It also includes functions to check for Prolog types and some utility
24       functions to perform explicit conversion between Prolog and Perl.
25

DESCRIPTION

27       This module define abstract classes for the usual Prolog functors,
28       lists, variables and nil.
29
30       Atoms are not included because perl scalars do the work.
31
32       Perl "undef" is equivalent to Prolog nil ("[]"), although a different
33       representation is allowed for the Prolog term.
34
35       Perl lists can be directly used as Prolog lists. The inverse is not
36       always true and depends of the implementations used.
37
38   EXPORT
39       prolog_is_term($term)
40           returns true if $term is a valid Prolog term (actually a perl
41           number, string or array or any object descending from
42           Language::Prolog::Types::Term).
43
44       prolog_is_atom($term)
45           returns true if $term is a valid Prolog atom (actually a perl
46           number or string).
47
48       prolog_is_nil($term)
49           returns true if $term is Prolog nil value ("[]").
50
51       prolog_is_functor($term)
52           returns true if $term is a Prolog functor.
53
54           It should be noted that lists are equivalent to functor '.'/2 and
55           because of that, this function will also return true when $term is
56           a list.
57
58       prolog_is_list($term)
59           returns true if $term is a Prolog list.
60
61           It should be noted that although Prolog nil is usually represented
62           as the empty list "[]", it is not really a Prolog list and this
63           function will return false for it.
64
65       prolog_is_list_or_nil($term)
66           returns true if $term is Prolog nil or a list.
67
68       prolog_is_variable($term)
69       prolog_is_var($term)
70           return true if $term is a free (unbounded) Prolog variable
71
72       prolog_is_ulist($term)
73           returns true if $term is an unfinished Prolog list, that means, one
74           with doesn't end in nil. i.e. difference lists.
75
76       prolog_list2perl_list($term)
77           converts a Prolog list or nil to a Perl array.
78
79       prolog_list2perl_string($list)
80           Strings are usually represented in Prolog as lists of numbers. This
81           function do the oposite conversion, from a list of numbers to a
82           Perl string.
83
84           It should be noted that all the elements in the Prolog list have to
85           be integers in the range [0..255] or an execption will be raised.
86
87   ABSTRACT CLASSES
88       Language::Prolog::Types::Term
89
90       common abstract class for every Prolog term.
91
92       Language::Prolog::Types::ListOrNil
93
94       This class is used to account for the intrinsec differences between
95       empty lists in Perl and Prolog.
96
97       In Prolog, nil although represented as the empty list, is not really a
98       list.
99
100       This class provides a set of methods that apply both to lists and nil
101       if it is considered to be the empty list.
102
103       BTW, you should mostly ignore this class and use
104       Prolog::Language::Types::Nil or Prolog::Language::Types::List instead.
105
106       Inherits:
107
108       Language::Prolog::Types::Term
109
110       Methods:
111
112       "$lon->length()"
113           returns the number of terms in the list. If the list is unfinished,
114           the tail is not counted.
115
116       "$lon->largs()"
117           returns the terms in the list. If the list is unfinished, the tail
118           is ignored.
119
120       "$lon->tail()"
121           returns the list tail, that will be nil if the list is finished or
122           is nil
123
124       "$lon->larg($index)"
125           returns element number $index on the list, if $index is negative,
126           the list is indexed from the end.
127
128       Language::Prolog::Types::Nil
129
130       Common abstract class for Prolog nil term representation.
131
132       Inherits
133
134       Language::Prolog::Types::ListOrNil
135
136       Methods
137
138       This class doesn't define any method on its own.
139
140       Language::Prolog::Types::Variable
141
142       Common abstract class for Prolog variable representation.
143
144       Inherits:
145
146       Language::Prolog::Types::Term
147
148       Methods:
149
150       "$var->name()"
151           returns the variable name.
152
153       Language::Prolog::Types::Functor
154
155       Common abstract class for Prolog functor representations.
156
157       Inherits:
158
159       Language::Prolog::Types::Term
160
161       Methods:
162
163       "$f->functor()"
164           returns the functor name.
165
166       "$f->arity()"
167           returns the number of arguments of the functor.
168
169       "$f->fargs()"
170           returns the arguments of the functor.
171
172       "$f->farg($index)"
173           returns the argument of the functor in the position $index, if
174           $index is negative the arguments are indexed begining from the end.
175
176           Be aware that arguments are indexed from 0, not from 1 as in
177           prolog.
178
179       Language::Prolog::Types::List
180
181       Common abstract class for Prolog list representations.
182
183       Inherits:
184
185       Language::Prolog::Types::Functor
186           A Prolog list is actually the functor '.'/2. i.e.
187
188             [1, 4, hello, foo]
189
190           is equivalent to:
191
192             '.'(1, '.'(4, '.'(hello, '.'(foo, []))))
193
194       Language::Prolog::Types::ListOrNil
195           List methods are shared with Language::Prolog::Types::Nil and this
196           is the reasong, to descent also from this class.
197
198       Methods:
199
200       "$l->car()"
201           returns the list "car".
202
203       "$l->cdr()"
204           returns the list "cdr".
205
206       "$l->car_cdr()"
207           returns both the "car" and the "cdr" of the list.
208
209       Language::Prolog::Types::UList
210
211       Common abstract class to represent unfinished lists (those whose tail
212       is not nil).
213
214       Inherits:
215
216       Language::Prolog::Types::List
217
218       Methods:
219
220       None of its own.
221
222       Language::Prolog::Types::Unknow
223
224       just in case...
225
226       Inherits:
227
228       Language::Prolog::Types::Term
229
230       Methods:
231
232       None.
233
234       Language::Prolog::Types::Opaque
235
236       This class should be only used by Prolog <-> Perl interface authors.
237
238       Usually Perl objects are converted to Prolog structures when passed to
239       a Prolog implementation. This class defines a proxy that stops the
240       conversion to happen and just pass a reference to the Perl object.
241
242       Opaque objects should not be returned from Prolog interfaces, they
243       should only be used to indicate to the Prolog implementations to not
244       convert Perl data to Prolog. When returning from Prolog the original
245       object should be directly returned to improve usability.
246
247       It should be noted that not all prolog implementations would support
248       this type.
249
250       Inherits:
251
252       Language::Prolog::Types::Term
253
254       Methods:
255
256       "$this->opaque_reference"
257           returns the object that it shields from prolog
258
259       "$this-">opaque_comment>
260           returns comment string that will show in Prolog representation
261
262       "$this-">opaque_class>
263           returns object class as should been seen from Prolog side
264
265       Language::Prolog::Types::Opaque::Auto
266
267       Not really an abstract class but a simple implementation to be used as
268       a base class to provide automatic opacity to objects.
269
270       So, objects of any class that has it as an ancestor will be passed to
271       prolog as a reference.
272

SEE ALSO

274       Language::Prolog::Types.
275
276       Language::Prolog::Types::Internal contains an actual implementation for
277       the classes defined in this module.
278
279       Any good Prolog book will also help :-)
280

AUTHOR

282       Salvador Fandiño, <sfandino@yahoo.com>
283
285       Copyright 2002-2007 by Salvador Fandiño
286
287       This library is free software; you can redistribute it and/or modify it
288       under the same terms as Perl itself.
289

POD ERRORS

291       Hey! The above document had some coding errors, which are explained
292       below:
293
294       Around line 592:
295           Non-ASCII character seen before =encoding in 'Fandiño,'. Assuming
296           CP1252
297
298
299
300perl v5.36.0                      2023-01-2L0anguage::Prolog::Types::Abstract(3)
Impressum