Did you know ... | Search Documentation: |
record.pl -- Access compound arguments by name |
This module creates a set of predicates to create a default instance, access and modify records represented as a compound term.
The full documentation is with record/1, which must be used as a directive. Here is a simple example declaration and some calls.
:- record point(x:integer=0, y:integer=0). default_point(Point), point_x(Point, X), set_x_of_point(10, Point, Point1), make_point([y(20)], YPoint),
Used a directive, :- record Constructor(Arg, ...)
is expanded
info the following predicates:
<constructor>_<name>
(Record, Value)<constructor>_data
(?Name, ?Record, ?Value)default_<constructor>
(-Record)is_<constructor>
(@Term)make_<constructor>
(+Fields, -Record)make_<constructor>
(+Fields, -Record, -RestFields)set_<name>_of_<constructor>
(+Value, +OldRecord, -New)set_<name>_of_<constructor>
(+Value, !Record)nb_set_<name>_of_<constructor>
(+Value, !Record)set_<constructor>_fields
(+Fields, +Record0, -Record).set_<constructor>_fields
(+Fields, +Record0, -Record, -RestFields).set_<constructor>_field
(+Field, +Record0, -Record).user:current_record
(:<constructor>)make_<constructor>(Fields, Record) :- make_<constructor>(Fields, Record, []) make_<constructor>(Fields, Record, RestFields) :- default_<constructor>(Record0), set_<constructor>_fields(Fields, Record0, Record, RestFields). set_<constructor>_fields(Fields, Record0, Record) :- set_<constructor>_fields(Fields, Record0, Record, []). set_<constructor>_fields([], Record, Record, []). set_<constructor>_fields([H|T], Record0, Record, RestFields) :- ( set_<constructor>_field(H, Record0, Record1) -> set_<constructor>_fields(T, Record1, Record, RestFields) ; RestFields = [H|RF], set_<constructor>_fields(T, Record0, Record, RF) ). set_<constructor>_field(<name1>(Value), Record0, Record). ...
data(Name, Record, Value)
predicate.