tests/accumulator/*.m:
tests/analysis_*/*.m:
tests/benchmarks*/*.m:
tests/debugger*/*.{m,exp,inp}:
tests/declarative_debugger*/*.{m,exp,inp}:
tests/dppd*/*.m:
tests/exceptions*/*.m:
tests/general*/*.m:
tests/grade_subdirs*/*.m:
tests/hard_coded*/*.m:
Make these tests use four-space indentation, and ensure that
each module is imported on its own line. (I intend to use the latter
to figure out which subdirectories' tests can be executed in parallel.)
These changes usually move code to different lines. For the debugger tests,
specify the new line numbers in .inp files and expect them in .exp files.
Estimated hours taken: 1.5
Branches: main
library/random.m:
Provide better documentation on how (not) to use the random number
generator in the standard library. Generators of this kind are
very sensitive to the way in which they are used, and if used
in a way not anticipated they can give very poor results.
XXX The standard library really should provide a better quality RNG.
There is still a place for quick and dirty RNGs like this one,
though, provided users are given adequate information about the
pitfalls.
One of the pitfalls to avoid is that you shouldn't use mod (or rem)
to reduce a number down to some desired range, you should use
something like div. We therefore provide a predicate that does
this the prescribed way. We also provide a predicate that is
similar to randmax, but returns the number of distinct random
numbers that can be generated instead of the maximum.
Fix random__permutation to avoid the above pitfall.
Replace some occurrences of is/2 with =/2.
NEWS:
Mention the new predicate.
tests/hard_coded/Mmakefile:
tests/hard_coded/random_permutation.exp:
tests/hard_coded/random_permutation.m:
A test case for random__permutation. We don't test that the
result is "random", but we at least test that it is a permutation.
tests/hard_coded/random_simple.exp:
tests/hard_coded/random_simple.m:
A simple test that checks for off-by-one errors in random__random/5.
tests/hard_coded/stable_sort.m:
tests/hard_coded/test_bitset.exp:
tests/hard_coded/test_bitset.m:
Fix these tests to avoid the above pitfall. The bitset tester also
needed to be modified so that it doesn't output anything that may
depend on the particular random sequence generated.
Estimated hours taken: 3
Branches: main
Remove the assumption on user supplied comparison predicates that
C(X, Y, =) implies X = Y (similarly for comparison functions). Our code
shouldn't need to assume this, and sometimes more general orderings are
useful (for example, when you only want to compare the key of a key-value
pair). The existing assumptions were not documented anywhere, so we now
document the remaining assumptions in builtin.m.
With this assumption gone the issue of the stability of library sorting
predicates that allow a user supplied ordering arises, since elements may
be equivalent according to the ordering even though they are not equal.
Therefore modify the documentation of standard library predicates to make
clear what we do with equivalent elements, and make minor modifications to
the code to ensure that it does as we claim.
Although the builtin comparison predicates are guaranteed to satisfy the
assumption, we nevertheless remove it from the implementation of predicates
in list.m that use builtin comparison. The rationale for this is that we
don't need the assumption, and it may not be robust if in future we ever
decide to allow user defined comparison.
NEWS:
Mention the changed assumptions about user supplied comparison
predicates and functions.
Mention the new predicate exported from list.m.
library/builtin.m:
Add types comparison_pred/1 and comparison_func/1, and corresponding
insts. Document the assumptions we make about comparison predicates
and functions.
library/list.m:
Modify sort/3, sort_and_remove_dups/3, merge/4 and
merge_and_remove_dups/4, as well as any functional versions, to use
the new types. Document the stability of sorting, and modify the
code to ensure that we conform to this.
Add remove_adjacent_dups/3, which takes a user supplied comparison
predicate and determines whether elements are duplicates based on
this, rather than the usual equality.
Modify the implementation of some predicates that use compare, to
avoid the unnecessary assumption.
Fix some spelling and grammatical errors.
library/array.m:
library/bt_array.m:
Modify the interface of {,bt_}array__bsearch to use the new types
and insts. Update the documentation.
tests/hard_coded/Mmakefile:
tests/hard_coded/stable_sort.exp:
tests/hard_coded/stable_sort.m:
A test case that checks the stability of list__sort.