Files
mercury/extras/references/README
Warwick Harvey 5ffdd46a80 This change basically exposes the C types used for implementing the
Estimated hours taken: 12 (this figure a wild guess, because most of this
stuff was done about 6 months ago and left to rot).

This change basically exposes the C types used for implementing the
`reference' and `nb_reference' types in extras/references, so that if the
user wishes to allocate these types somewhere other than on the heap, they
can.  This is needed by HAL in order to implement global variables.

extras/references/c_reference.h:
        New file, intended to expose the C types used by the `reference'
        and `nb_reference' modules, so that the user can allocate them
        somewhere other than on the heap if they need to.

extras/references/nb_reference.m:
        Added a new predicate `init/2' for initialising a user-allocated
        `nb_reference'.

extras/references/reference.m:
        Moved the `ME_Reference' type to c_reference.h, and added a new
        predicate `init/2' for initialising a user-allocated `reference'.

extras/references/README:
        Added entries for the new `c_reference.h' and `tests/glob_test.m'
        files, as well as correcting the name of `tests/ref_test.m'.

extras/references/tests/Mmakefile:
        Added `glob_test' to the list of programs to build.

extras/references/tests/glob_test.m:
        Test case for statically-allocated reference types, implementing
        global variables.  Adapted from output from the HAL compiler.

extras/references/tests/glob_test.exp:
        Expected output from `glob_test'.
2000-01-28 03:37:14 +00:00

36 lines
1.2 KiB
Plaintext

This directory contains two impure reference type modules, and a
module that allows scoped non-backtrackable update, plus two
example modules using these types. These serve as an example of
impure coding. Generally this sort of coding is not necessary, and it
can be quite tedious and error-prone, but occasionally it may permit
greater efficiency than using pure Mercury code, or may permit you to
write in Mercury what you would otherwise have to write in C. See
the "Impurity declarations" chapter of the Mercury Language Reference
Manual for more information on impurity.
This directory contains
reference.m a backtrackable reference types
nb_reference.m a non-backtrackable reference types
scoped_update.m scoping for non-backtrackable updates
global.m a wrapper module used for building a
library containing the above modules
c_reference.h C types used to implement the reference
types
The samples directory contains
max_of.m an example of non-backtrackable references
test_max.m test case for max_of.m
The tests directory contains
ref_test.m tests of reference.m, nb_reference.m
and scoped_update.m
glob_test.m tests use of c_reference.h to implement
global variables