library/diet.m:
library/fat_sparse_bitset.m:
library/set.m:
library/set_bbbtree.m:
library/set_ctree234.m:
library/set_ordlist.m:
library/set_tree234.m:
library/set_unordlist.m:
library/sparse_bitset.m:
library/tree_bitset.m:
Delete predicates and functions that have been marked as obsolete
since at least 2019.
Adjust documentation as required.
NEWS:
Announce the deletions.
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.
library/set.m:
library/set_bbbtree.m:
library/set_ctree234.m:
library/set_ordlist.m:
library/set_tree234.m:
library/set_unordlist.m:
Mark empty/1 and non_empty/1 as obsolete with is_empty and is_non_empty
as suggested replacements, and mark set/1 as obsolete with list_to_set/1
as suggested replacement.
NEWS:
Mention the above changes.
configure.ac:
Require the installed compiler to handle suggested replacements
in obsolete pragmas.
compiler/analysis.m:
Avoid calling the newly obsolete predicates.
Remove a workaround that probably hasn't been needed in a long time.
compiler/error_util.m:
compiler/hlds_args.m:
compiler/intermod.m:
compiler/make.dependencies.m:
compiler/make.module_dep_file.m:
compiler/mercury_compile_main.m:
compiler/module_cmds.m:
compiler/old_type_constraints.m:
compiler/options.m:
compiler/ordering_mode_constraints.m:
compiler/par_conj_gen.m:
compiler/parse_pragma.m:
compiler/prog_ctgc.m:
compiler/rbmm.add_rbmm_goal_infos.m:
compiler/rbmm.live_region_analysis.m:
compiler/structure_reuse.domain.m:
compiler/structure_reuse.versions.m:
compiler/structure_sharing.domain.m:
compiler/switch_detection.m:
compiler/term_constr_fixpoint.m:
compiler/term_constr_util.m:
compiler/tupling.m:
deep_profiler/analysis_utils.m:
deep_profiler/autopar_annotate.m:
deep_profiler/autopar_calc_overlap.m:
deep_profiler/recursion_patterns.m:
deep_profiler/var_use_analysis.m:
Avoid calling the newly obsolete predicates.
library/set*.m:
Add det_remove and det_remove_list predicates to the set modules
that did not yet have them.
Add rev_sorted_list_to_set in both predicate and function form
to the set modules that did not yet have such functionality.
Note: some modules had such a function, but not predicate.
This diff leaves those modules alone.
Document that the input to sorted_list_to_set predicates and functions
should not have duplicates, unless the predicate in question detects
and removes duplicates. The different set modules are inconsistent
in this regard.
Use consistent variable names.
NEWS:
Announce the new predicates and functions.
library/set.m:
Organize the predicates of this modules a lot better, clustering
related predicates into named groups, and imposing a meaningful order
both within and among groups.
library/set_bbbtree.m:
library/set_ctree234.m:
library/set_ordlist.m:
library/set_tree234.m:
library/set_unordlist.m:
Put the predicates of these modules into the same order as set.m
as far as possible given that some of these modules define predicates
that set.m doesn't, and vice versa.
Delete any redundant module qualifications in clause heads and predicate
and function declarations. In calls to error, use $pred to specify the
location.
library/Mercury.options:
Require the order of definitions in these modules to match the order
of declarations.
The implementation of a mutable requires several predicates, some user visible,
some not. Exactly what set of predicates a mutable needs depends both on its
attributes and on the target platform. Previously, we computed that set of
predicates three times:
- when adding their declarations to the HLDS,
- when adding their definitions to the HLDS, and
- when adding (a subset of) their declarations to a .int0 file.
This diff tries to centralizes these decisions in one place. It does not
quite get there, because getting there would require compromises that are
undesirable for other reasons, but it gets close.
compiler/prog_data.m:
Document the uses of the various kinds of predicates we can generate
for a mutable.
compiler/prog_mutable.m:
Add a predicate that decides which public auxiliary predicates
a mutable needs, for use by both add_mutable_aux_preds.m and by
comp_unit_interface.m.
Add a predicate that constructs the pred_decl item of any given
mutable auxiliary predicate, again for use by add_mutable_aux_preds.m
and by comp_unit_interface.m.
Move predicates that are used only by add_mutable_aux_preds.m
to add_mutable_aux_preds.m.
Delete predicates that are no longer needed.
compiler/add_mutable_aux_preds.m:
Add a predicate that decides which private auxiliary predicates
a mutable needs,
Use the new mechanisms above to declare a mutable's auxiliary procedures.
Use the new mechanisms above to define a mutable's auxiliary procedures,
mostly. There is still some code that repeats the logic of the decision
predicate for public auxiliary predicates, but now a sanity check
ensures that the two decision procedures arrived at the same result.
Move predicates that are used only by add_mutable_aux_preds.m
here from prog_mutable.m.
Delete predicates that are no longer needed.
Give several predicates more descriptive names. Standardize
argument orders.
compiler/add_pred.m:
Add a mechanism for adding a pred_decl item as a whole to the HLDS.
(Previously, we could a pred_decl to the HLDS by first breaking it down
to its components.) The code is mostly copied from make_hlds_passes.m.
compiler/comp_unit_interface.m:
Use the new mechanisms above to declare a mutable's auxiliary procedures.
The new code does not need any knowledge of what auxiliary predicates
a mutable needs.
compiler/make_hlds_passes.m:
Use the new mechanism in add_pred.m, in order to avoid code duplication.
library/set.m:
Add a new predicate for add_mutable_aux_preds.m.
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.
library/set.m:
library/set_ordlist.m:
library/set_ctree234.m:
library/set_tree234.m:
As above.
Make the divide operation faster in the 234 tree modules.
Remove unnecessary module qualifications. Give some internal predicates
better names.
NEWS:
Announce the new predicates.
compiler/*.m:
deep_profiler/*.m:
As above.
library/set.m:
library/set_bbbtree.m:
library/set_ctree234.m:
library/set_ordlist.m:
library/set_tree234.m:
library/set_unordlist.m:
Add is_non_empty to the set modules that did not already have it.
(Some did, some didn't.)
Make the documentation of empty, is_empty, non_empty and is_non_empty
consistent.
NOTE: this change does not affect the io module -- I've left that for a
separate change.
library/*.m:
As per the recent change to the coding standard, avoid module
qualification in library interfaces where possible.
Reformat declarations and descriptive comments to better utilise
any space freed up by the above.
Estimated hours taken: 1
Branches: main
library/set.m:
library/set_ordlist.m:
library/set_tree234.m:
Add foldl, foldl2, ... foldl6 as synonyms for fold, fold2, ... fold6.
This allows set_of_var.m to switch from tree_bitset.m to using these
modules with just e.g. g/MODULE/s/tree_bitset/set_tree234/g.
compiler/set_of_var.m:
Change the code to resolve an ambiguity that would otherwise arise
after such a substitution.
Estimated hours taken: 3
Branches: main
Avoid some redundant work during determinism analysis. This diff speeds up
tools/speedtest by just shy of 0.7%.
compiler/det_analysis.m:
Instead of (a) getting a list of procedures in the module and then
(b) classifying them into three categories, do both jobs at once.
This avoids some redundant traversals and map lookups, and avoids
the creation of an intermediate data structure.
compiler/instmap.m:
Instead of converting a set into a list and iterating over that list
to check that elements of the set have a given property, iterate over
the set elements directly.
Put the arguments of a predicate in a more logical order.
compiler/det_util.m:
Conform to the change in instmap.m.
compiler/set_of_var.m:
Provide the all_true predicate needed by det_util.
library/*set*.m:
In every module that implements sets, provide an all_true predicate.
NEWS:
Mention the new predicates in the library.
Estimated hours taken: 8
Branches: main
compiler/inst_match.m:
Instead of first testing whether an inst exists in a set
and then inserting it if does not, use a single predicate
that does both the membership test and the insertion (if
the membership test failed) in one pass.
This speeds up compilation of one version of the rcpsp_cpx
stress test by about 9%, with negligible effect on tools/speedtest.
Some cleanups that should have been committed before this diff follow.
Change the structure of many of the predicates in this module from
containing multiple clauses, to a single clause with an explicit
disjunction, which (where relevant) now gets a require_comple_switch
wrapper. In several cases, this change has shown that we were
missing code for handling some kinds of insts. For example, some
predicates handled free/0 but not free/1, even though there was
no reason for the difference. This diff fixes such oversights
in places where the right action seems obvious to me, and adds
XXXs in places where I see no obvious fix.
Rename several predicates and function symbols to avoid ambiguities.
Add some XXXs on potential problems.
library/*set*.m:
Implement this insert_new predicate for all the implementations
of sets we have. The code in each case is copied from the code
of insert, with code to return a set unchanged replaced with `fail'.
NEWS:
Mention the new predicates.
Branches: main
Update documentation for swapped arguments of `singleton_set/2' predicates.
library/set.m:
library/set_ordlist.m:
library/set_unordlist.m:
As above.
Branches: main, 11.07 (partial)
Fix bug #248: make the argument order of the singleton_set/2 predicates in the
various set modules in the standard library consistent. (This breaks backwards
compatibility but in a fairly minor way.)
Add the predicate is_singleton/2 to those set modules that do not already
provide it.
Fix a bug in the implementation of set_unordlist.singleton_set/2.
library/set.m:
library/set_bbbtree.m:
library/set_ctree234.m:
library/set_ordlist.m:
library/set_unordlist.m:
Swap the argument order of singleton_set/2.
Add is_singleton/2 where it wasn't already present.
library/set_unordlist.m:
Fix a bug: singleton_set/2 failed to take account of
the fact that the representation could contain duplicates
in the singleton_setT::out, set_unordlist(T)::in) mode.
The fix is to sort and remove the duplicates before checking
whether the set is singleton.
NEWS:
Announce the above changes.
library/eqvclass.m:
library/tree234.m:
compiler/accumulator.m:
compiler/code_info.m:
compiler/graph_colour.m:
compiler/higher_order.m:
compiler/lp_rational.m:
compiler/ml_tag_switch.m:
compiler/pd_info.m:
compiler/pd_util.m:
compiler/proc_gen.m:
compiler/prog_mode.m:
compiler/term_pass1.m:
compiler/type_constraints.m:
compiler/unneeded_code.m:
compiler/var_locn.m:
deep_profiler/autopar_costs.m:
deep_profiler/var_use_analysis.m:
tests/general/set_test.m:
Conform to the above changes.
tests/hard_coded/Mmakefile:
tests/hard_coded/singleton_dups.{m,exp}:
Add a regression test for the problem with set_unordlist.singleton_set/2.
Estimated hours taken: 1
Branches: main
compiler/stack_layout.m:
Avoid a set->list->set round-trip conversion.
library/set.m:
library/set_ordlist.m:
Add a predicate version of trues-only filter to make this possible.
Estimated hours taken: 3
Branches: main
compiler/stack_alloc.m:
Avoid some redundant conversions between lists and sets. The main
performance win is from avoiding a list_to_set conversion that
requires sorting.
library/*set*.m:
The change to stack_alloc.m requires the ability to partition a set
based on predicate. Implement a version of filter that returns the
false as well as the true cases in all the set modules. (Most set
modules lacked the return-the-trues-only version of filter as well.)
NEWS:
Mention the additions to the standard library.
Branches: main
Change the argument order of predicates in the set_bbbtree, set_ordlist, and
set_unordlist modules to (1) make them conducive to the use of state variable
notation and (2) make them consistent with the other modules that implement the
set ADT.
This change will break existing code that uses these modules, but such uses
should (and if Mercury and G12 are anything to go by, are) quite rare.
Group function clauses together with the clauses for the corresponding
predicates.
library/set_bbbtree.m:
library/set_ordlist.m:
library/set_unordlist.m:
As above.
Reorder the clauses in the set_ordlist module as the existing
order corresponds in no way to the order of declarations in
the module interface.
library/set.m:
tests/general/set_test.m:
Conform to the above changes.
library/dir.m:
Group predicate and function clauses together.
NEWS:
Announce the above changes.
Branches: main
Add predicates named is_empty/1 as a synonym for empty/1 to all the modules in
the standard library that provide sets. The former name is less ambiguous than
the latter.
library/set*.m:
library/spare_bitset.m:
library/tree_bitset.m:
Add is_empty/1 as a synonym for empty/1.
NEWS:
Announce the above addition.
Branches: main
Change the argument ordering of predicates in the set module.
library/set.m:
Change predicate argument orders to match the versions
in the svset module.
Group function definitions with the corresponding predicates
rather than at the end of the file.
Delete Ralph's comments regarding the argument order in the
module interface: readers of the library reference guide are
unlikely to be interested in his opinion of the argument ordering
ten or so years ago.
Add extra modes for set.map/3 and set.map_fold/5.
library/svset.m:
library/eqvclass.m:
library/tree234.m:
library/varset.m:
browser/*.m:
compiler/*.m:
deep_profiler/*.m:
mdbcomp/trace_counts.m:
extras/moose/grammar.m:
extras/moose/lalr.m:
extras/moose/moose.m:
tests/hard_coded/bitset_tester.m:
Conform to the above change.
NEWS:
Announce the above changes.
Branches: main, 11.01
Fix a couple of issues with some of the set types in the standard library
being used in type class instances.
library/set_unordlist.m:
Define set_unordlists using a notag type rather than an equivalence.
This allows them to be safely used in type class instances.
library/set.m:
Export the definition of the type set/1 in an undocumented interface
section. Not exporting it leads to problems when it used used in
type class instances (since it is defined using an abstract
equivalence). We don't want to use a notag wrapper here since that
would lead to some operations, e.g. power_union/2, being less efficient.
This should be ok; the abstraction barrier is still in place since set/1
is defined to be set_ordlist/1 (which is itself abstract).
tests/invalid/actual_expected.err_exp:
tests/invalid/overloading.err_exp:
Conform to the above changes.
Branches: main
Support folds over sets with six accumulators.
library/set.m:
library/set_bbbtree.m:
library/set_ctree234.m:
library/set_ordlist.m:
library/set_tree234.m:
library/set_unordlist.m:
As above.
library/list.m:
Add semidet modes for list.foldl6/14 with (mostly-) unique
accumulators.
NEWS:
Announce the above changes.
library modules that provide sets.
Support mostly-unique and unique accumulators in set folds.
(These were provided in some set modules, but not in others.)
library/set.m:
library/set_bbbtree.m:
library/set_ctree234.m:
library/set_ordlist.m:
library/set_tree234.m:
library/set_unordlist.m:
Add predicates for fold over sets with up to five accumulators.
As per the coding standard, where an operation has both a
function version and a predicate version, the declaration for
the function version should occur first in stdlib modules.
Fix up overlong lines.
library/set_bbbtree.m:
Add an XXX regarding the implementation of fold.
library/list.m:
Add additional modes to list.foldl3/8, list.foldl4/10,
and list.foldl5/12 required by the above.
NEWS:
Announce the changes.
Branches: main
library/set_tree234.m:
Swap order of arguments of `set_tree234.member/2' to match other
modules.
compiler/dead_proc_elim.m:
compiler/det_report.m:
compiler/det_util.m:
compiler/format_call.m:
compiler/inst_match.m:
compiler/llds_out_instr.m:
compiler/passes_aux.m:
compiler/post_typecheck.m:
compiler/switch_detection.m:
compiler/typecheck.m:
library/list.m:
Conform to change.
library/set.m:
library/set_ctree234.m:
library/set_ordlist.m:
library/set_unordlist.m:
Fix typos in documentation.
Estimated hours taken: 300
Branches: main
Created a constraint-based typechecker. The typechecker works by generating
a collection of constraints on the types of variables in each clause of the
program, then solving these constraints using propagation. Information on the
types of local variables (clauses_info^clauses_vartypes) and the IDs of
predicate calls (hlds_goal_expr^call_pred_id) is passed back into the HLDS.
In the event that the program being compiled is not type-correct, the
typechecker will generate an error message describing the error. If the
constraints on a variable cannot fully determine a type, the typechecker will
report each possible type the variable could take. If the constraints on the
type of a variable are unsatisfiable, the compiler will report each minimal
unsatisfiable subset of the constraints, pointing out the likely location(s)
of the error.
The constraint-based typechecker can handle ambiguous predicate calls and
functor unifications much more efficiently than the old typechecker. However,
it cannot handle anything related to existentially qualified variables,
typeclass constraints and typeclass methods. The detail and clarity of error
reporting is also rather poor.
These changes have not yet been comprehensively debugged, although it
should work in most cases, given the exceptions detailed above.
To use the constraint-based typechecker instead of the original typechecker,
enable the option --type-check-constraints when compiling your program.
compiler/type_constraints.m:
Built from scratch.
compiler/mercury_compile.m:
Imported the constraint-based typechecker.
Enabled constraint-based typechecking if the --type-check-constraints
option is set.
compiler/options.m:
Added the --type-check-constraints option.
library/list.m:
Added a list.filter_map_foldl predicate.
library/set.m:
Added a predicate version of set.filter_map.
NEWS:
Mention the new library predicates.
Estimated hours taken: 1
Branches: main
Improve support for mostly-uniqueness in the standard library.
library/bimap.m:
library/list.m:
library/map.m:
library/set.m:
library/tree234.m:
Add modes to fold style predicates with mostly-unique accumulators.
Add semidet versions of fold style predicate with unique accumulators.
Re-order the mode declarations for the above predicates; in a lot
of cases the ordering made it difficult to see if a required mode
was actually present. The new ordering is by determinism and then
by uniqueness.
NEWS:
Announce the additions.
Estimated hours taken: 0.1
Branches: main
library/set.m:
Add a predicate version of set.map.
library/map.m:
Fix some variable names, and some style issues.
Estimated hours taken: 0.2
Branches: main
Formatting and style fixes for standard library modules.
Fix a bunch of minor problems, e.g. unnecessary module imports.
library/bitmap.m:
s/memcpy/MR_memcpy/ in a spot.
Call throw/1 rather than error/1 and don't import the require
module.
library/term_to_xml.m:
Don't import the require module. It is unused here.
library/time.m:
Add some missing `thread_safe' annotations.
library/bool.m:
library/cord.m:
library/gc.m:
library/multi_map.m:
library/queue.m:
library/rtti_implementation.m:
library/set.m:
library/set_bbbtree.m:
library/svarray.m:
library/svbag.m:
library/svbimap.m:
library/sveqvclass.m:
Formatting and style fixes.
Estimated hours taken: 0
Branches: main
Extending the comment of set.count/2 so that people can find it using different keywords.
set.m:
Trivial change, added some keywords to the comment, so that people
can find the predicate.
Estimated hours taken: 3
Branches: main
Clean up in unused module imports in the Mercury system detected
by --warn-unused-imports.
analysis/*.m:
browser/*.m:
deep_profiler/*.m:
compiler/*.m:
library/*.m:
mdbcomp/*.m:
profiler/*.m:
slice/*.m:
Remove unused module imports.
Fix some minor departures from our coding standards.
analysis/Mercury.options:
browser/Mercury.options:
deep_profiler/Mercury.options:
compiler/Mercury.options:
library/Mercury.options:
mdbcomp/Mercury.options:
profiler/Mercury.options:
slice/Mercury.options:
Set --no-warn-unused-imports for those modules that are used as
packages or otherwise break --warn-unused-imports, e.g. because they
contain predicates with both foreign and Mercury clauses and some of
the imports only depend on the latter.
Estimated hours taken: 1
Branches: main
Various minor cleanups and syntax updates for the standard library.
There are no changes to any algorithms.
library/injection.m:
library/set.m:
library/sparse_bitset.m:
Use promise_equivalent_clauses where appropriate.
library/set_ordlist.m:
library/set_unordlist.m:
Convert these module to 4-space indentation:
Convert these module to 4-space indentation
library/*.m:
Convert some if-then-elses into switches.
Remove unnecessary module qualification - this is related
mainly to the breakup of std_util and the fact that on
the 0.13 branche we had two versions of the all-solutions
predicates.
Various other style cleanups.
vim/syntax/mercury.vim:
Highlight promise_equivalent_clauses appropriately.
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: 1
Branches: main
library/*.m:
Replace __ with . as the module qualifier everywhere.
tests/hard_coded/test_injection.exp:
Replace __ with . as the module qualifier in expected exceptions.
Estimated hours taken: 0.1
Branches: main
Add set.fold4/10 to the standard library.
library/set.m:
Add set.fold4/10.
NEWS:
Mention the new predicate.
Merge all of the new predicates in the list module into
one section.
Estimated hours taken: 4
Branches: main
library/*.m:
Convert to four-space indentation most of the library modules that
weren't already indented that way. Use predmode syntax where possible.
In some modules, shorten long lines by deleting module name prefixes.
Fix departures from our coding standards.
In some modules, simplify code, mostly using field names and/or state
variables.
There are no changes in algorithms, except for neg_list in integer.m.
Estimated hours taken: 3
Branches: main, version-0_12-branch
library/array.m:
library/array2d.m:
library/assoc_list.m:
library/bag.m:
library/benchmarking.m:
library/bimap.m:
library/bintree_set.m:
library/bitmap.m:
library/bool.m:
library/builtin.m:
library/cord.m:
library/float.m:
library/graph.m:
library/group.m:
library/hash_table.m:
library/int.m:
library/lexer.m:
library/list.m:
library/map.m:
library/math.m:
library/multi_map.m:
library/ops.m:
library/parser.m:
library/rbtree.m:
library/set.m:
library/stack.m:
library/store.m:
library/string.m:
library/time.m:
Minor reformatting; added some renamed preds and funcs to improve
consistency of naming in the library; removed some preds and types that
have been marked obsolete since 0.11.
Estimated hours taken: 3.5
Branches: main
Make the positioning of descriptive comments conform
to the coding standard for the following library modules.
Convert preds to predmode syntax where possible.
Make the ordering of related predicates and functions
conform to the coding standard, where the descriptive
comment makes it possible to do that.
Other minor changes are listed below.
library/bimap.m:
Fix capitalisation of a few comments.
library/dir.m:
s/throw an exception/throws an exception/.
library/exception.m:
Fix the comment about the exception_result/1 type.
There is only one type and an inst following the comment.
library/map.m:
Remove the unique modes for map.set/4, map.delete/3 and
map.delete_list/3.
library/rbtree.m:
Remove the unique modes for rbtree.set/4, rbtree.delete/3,
rbtree.remove/4, rbtree.remove_smallest/4 and rbtree.remove_largest/4.
library/tree234.m:
Remove left over unique modes for preds.
library/set.m:
XXX the ordering of procedures in this module is a bit strange.
library/set_bbbtree.m:
library/set_unordlist.m:
Remove various unique modes for set operations like
delete/3. (Some of these were commented out anyway).
library/term_to_xml.m:
Fix a spot where line width exceeded 79 characters.
library/array.m:
library/assoc_list.m:
library/random.m:
library/multi_map.m:
library/pqueue.m:
library/queue.m:
library/bool.m:
library/char.m:
library/construct.m:
library/counter.m:
library/deconstruct.m:
library/eqvclass.m:
library/gc.m:
library/io.m:
library/sparse_bitset.m:
library/stack.m:
library/std_util.m:
library/store.m:
library/string.m:
library/term.m:
library/term_io.m:
library/type_desc.m:
library/varset.m:
As above.
Estimated hours taken: 0.2
Branches: main
library/set.m:
library/set_ordlist.m:
Take advantage of the sortedness of the lists we use to represent sets
to stop set membership tests as soon as we have gone past the position
where the searched-for item should be. This improves performance by
about 1%.