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.


FacilityTypeAccessSee
shelvesarrayby handleshelf_create/2,3
bagsunordered bagby handlebag_create/1
storeshash tableby handlestore_create/1
anonymous recordsordered listby handlerecord_create/1
named shelvesarrayby nameshelf/2
named storeshash tableby namestore/1
non-logical variablessingle cellby namevariable/1
non-logical arraysarrayby namearray/1,2
recordsordered listby namerecord/1,2
dynamic predicatesordered listby namedynamic/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