Up Next

9.1  Introduction

This chapter describes primitives that allow to break the normal logic programming rules in two ways: Obviously, these facilities must be used with care and should always be encapsulated in an interface that provides logical semantics.

ECLiPSe provides several facilities to store information across backtracking. The following table gives an overview. If at all possible, the handle-based facilities (bags, shelves and stores) should be preferred because they lead to cleaner, reentrant code (without global state) and reduce the risk of memory leaks.

Facility Type Access See
shelves array by handle shelf_create/2,3
bags unordered bag by handle bag_create/1
stores hash table by handle store_create/1
named shelves array by name shelf/2
named stores hash table by name store/1
non-logical variables single cell by name variable/1
non-logical arrays array by name array/1,2
records ordered list by name record/1,2
dynamic predicates ordered list by name dynamic/1,assert/1

The other facility described here, Global References, does not store information across failure, but provides a means to give a name to an otherwise logical data structure. See section 9.7.

Up Next