Up Next

10.1  Introduction

This chapter describes primitives that allow one 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, record, shelves and stores) should be preferred because they lead to cleaner, reentrant code (without global state) and reduce the risk of memory leaks.


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


Up Next