[ Recorded Database | Reference Manual | Alphabetic Index ]

record_create(-Handle)

Create an anonymous record handle
Handle
Variable, will be bound to a handle.

Description

This creates an anonymous 'record' object which can store an ordered list of terms, and whose contents are unaffected by backtracking.

Records can be referred to either by handle or by name. Whenever possible, handles should be used, because this naturally leads to robust, reentrant code, and avoids the danger of memory leaks. An anonymous record disappears when the system backtracks over its creation, when the record handle gets garbage collected, or when it is explicitly destroyed.

When named records are used, the visibility of the record name is local to the module where it was created. A named record never disappears, therefore, in order to free the associated memory, its contents should be erased when no longer needed.

Modes and Determinism

Examples

	?- record_create(R), record(R,a), record(R,b), recorded_list(R,L).
	L = [a,b]

	?- record_create(R),
	   ( member(X,[a,b,c]), record(R,X), fail
	   ; recorded_list(R,L)
	   ).
	L = [a,b,c]

See Also

is_record / 1, record / 1, record / 2, recorded / 2