NEWS:
Mention all the user-visible changes below.
library/enum.m:
Add the typeclass uenum, which is a version of the existing enum typeclass
that maps items to uints, not ints. It also uses a semidet predicate,
not a semidet function, to get back to the item from the uint.
library/sparse_bitset.m:
library/fat_sparse_bitset.m:
Make these modules operate on uints, which means requiring the items
in the sets to be instances of uenum, not enum.
If a few places, improve loops by doing previously-repeated conversions
of [u]ints into <offset, bit-to-set> pairs just once.
library/counter.m:
Define ucounters, which allocate uints. Improve documentation.
library/digraph.m:
Change digraph_keys from ints to uints, since we put them into
sparse_bitsets.
library/int.m:
Make int an instance of the uenum typeclass. This can help users
who currently put ints into sparse_bitsets.
library/pprint.m:
Prettyprint sparse_bitsets as lists of uints.
library/term.m:
Make vars instances of uenum as well as enum.
library/uint.m:
Make uint an instance of the uenum typeclass.
Add the ubits_per_uint function, which allows some casts to be avoided.
compiler/make.deps_set.m:
Change the indexes we put into sparse_bitsets from ints to uints.
compiler/make.make_info.m:
Change the source of those indexes from ints to uints.
compiler/make.top_level.m:
compiler/make.util.m:
Conform to the changes above.
compiler/pre_quantification.m:
Change zones from ints to uints, since we put them into sparse_bitsets.
tests/hard_coded/int_uenum.{m,exp}:
tests/hard_coded/Mmakefile:
Enable the new test case.
tests/valid/use_import_only_for_instance.m:
Update this extract from library/digraph.m the same way as
library/digraph.m itself.
In the Mercury standard library, every exported predicate or function
has (or at least *should* have) a comment that documents it, including
the meanings of its arguments. About 35-40% of these modules put `'s
(left and right quotes) around the names of the variable representing
those arguments. Some tried to do it consistently (though there were spots
with unquoted or half quoted names), while some did it only a few places.
This is inconsistent: we should either do it everywhere, or nowhere.
This diff makes it nowhere, because
- this is what the majority of the standard library modules do;
- this is what virtually all of the modules in the compiler, profiler,
deep_profiler etc directories do;
- typing all those quotes when adding new predicates in modules that
follow this convention is a pain in the ass; and because
- on many modern terminals, `' looks non-symmetrical and weird.
Likewise, the comment explaining a predicate often started with
% `predname(arguments)' returns ...
This diff deletes these quotes as well, since they add nothing useful.
This diff does leave in place quotes around code fragments, both terms
and goals, where this helps delineate the boundaries of that fragment.
Discussion of these changes can be found on the Mercury developers
mailing list archives from June 2018.
COPYING.LIB:
Add a special linking exception to the LGPL.
*:
Update references to COPYING.LIB.
Clean up some minor errors that have accumulated in copyright
messages.
Add a function enum.det_from_int, as requested by Julien and Zoltan.
library/enum.m:
library/diet.m:
Move det_from_int from diet to enum.
tests/hard_coded/bitmap_simple.m:
Remove redundant and conflicting definition.
Estimated hours taken: 0.2
Branches: main, release
library/*.m:
Improve the library reference manual by formatting the beginning of
library modules consistently.
library/integer.m:
Fix some bad indentation.
Estimated hours taken: 14
Use bitsets to store the sets of variables in quantification.
This change reduces the time taken by `mmc -C make_hlds' by 7-8%.
library/sparse_bitset.m:
An ADT for storing sets of integers.
library/set.m:
library/set_ordlist.m:
library/set_unordlist.m:
library/set_bbbtree.m:
library/bintree_set.m:
Add a predicate contains/2, which is like member/2 but
only has the `contains(in, in)' mode. For some set representations
it is difficult to code a predicate which does both the
`member(out, in)' and `member(in, in)' modes efficiently.
library/enum.m:
Contains a typeclass `enum/1' describing types which
can be converted to and from integers.
library/term.m:
Add an instance declaration for `enum(var(T))'.
library/char.m:
Add an instance declaration for `enum(character)'.
library/bool.m:
Add an instance declaration for `enum(bool)'.
library/int.m:
Add an instance declaration for `enum(int)'.
Add a function for finding the largest multiple of
bits_per_int which is less than a given number, for
use by sparse_bitset.m.
compiler/quantification.m:
Use `sparse_bitset(prog_var)' rather than `set(prog_var)'
for all the sets of variables used while quantifying a goal,
but arrange things so that it is simple use `set(prog_var)'
when debugging.
library/library.m:
compiler/modules.m:
Add `enum' and `sparse_bitset' to the list of library modules.
NEWS:
Document the new modules.
tests/hard_coded/Mmakefile:
tests/hard_coded/test_sparse_bitset.m:
tests/hard_coded/bitset_tester.m:
Add some tests for predicates and functions in
sparse_bitset.m which are not used in quantification.m.
Test storing negative integers in sparse_bitsets.