17 Commits

Author SHA1 Message Date
Julien Fischer
b85f11b41d Fix library documentation errors.
library/*.m:
    As above.

library/getopt.m:
    Regenerate this file.
2026-01-22 21:22:38 +11:00
Zoltan Somogyi
94fadf1797 Add uint versions of array operations.
library/array.m:
    Add uint versions of most of this module's operations.

NEWS.md:
    Mention the new operations.

library/edit_distance.m:
    Use the new array operations to eliminate some casts.

library/edit_seq.m:
    Minor style fix.

tests/hard_coded/array_gen.{m,exp}:
tests/hard_coded/array_test_2.{m,exp}:
    Extend the tests of array.m's operations to the corresponding uint
    versions. Expect the output for the new versions.

tests/hard_coded/array_resize.m:
tests/hard_coded/array_shrink.m:
    Extend the tests of array.m's operations to the corresponding uint
    versions, but generate output only if their results differ from the
    original int versions. (They don't differ.)

tests/hard_coded/array_primitives.m:
    Style fixes.
2026-01-08 03:47:09 +11:00
Zoltan Somogyi
3f72528869 Update module stability levels. 2025-08-11 22:32:52 +02:00
Zoltan Somogyi
3ba06086be Update copyright notices. 2025-01-24 13:34:34 +11:00
Zoltan Somogyi
dcf48e2315 Add a new option, --warn-unsorted-import-blocks.
compiler/options.m:
doc/user_guide.texi:
NEWS.md:
    Add, document and announce the new option. It is off by default,
    but of course I tested its behavior when turned on. Most of this
    diff deals with the consequences.

compiler/item_util.m:
    Add code to generate the new warnings if requested.

compiler/convert_parse_tree.m:
    Request the new warning if the new option is set when processing
    source files..

compiler/handle_options.m:
    Disable all style warnings, including the new one, when generating
    .int* files or .*opt files.

compiler/mercury_compile_main.m:
    Fix an unrelated bug I noticed while working on this diff:
    report the "unfindability" of a given file at most once.

browser/dl.m:
browser/io_action.m:
compiler/mercury_compile_augment.m:
compiler/mercury_compile_llds_back_end.m:
compiler/unused_args.m:
deep_profiler/autopar_find_best_par.m:
deep_profiler/dump.m:
deep_profiler/html_format.m:
deep_profiler/mdprof_create_feedback.m:
deep_profiler/profile.m:
deep_profiler/read_profile.m:
deep_profiler/recursion_patterns.m:
deep_profiler/var_use_analysis.m:
library/array2d.m:
library/bit_buffer.read.m:
library/construct.m:
library/edit_distance.m:
library/library.m:
library/mercury_term_lexer.m:
library/one_or_more_map.m:
library/private_builtin.m:
library/set_bbbtree.m:
library/string.parse_runtime.m:
library/thread.future.m:
library/univ.m:
library/version_array.m:
library/version_bitmap.m:
mdbcomp/program_representation.m:
profiler/call_graph.m:
profiler/demangle.m:
profiler/output.m:
profiler/process_file.m:
profiler/propagate.m:
slice/mdice.m:
slice/mslice.m:
    Fix unsorted import blocks pointed out by the new option.

tests/invalid/ambiguous_overloading_error.err_exp:
tests/invalid/bad_tscp.err_exp:
tests/invalid/bug10.err_exp:
tests/invalid/gh72_errors.err_exp:
tests/invalid/ho_default_func_2.err_exp:
tests/invalid/require_scopes.err_exp:
tests/invalid/type_error_use_module.err_exp:
tests/invalid/types.err_exp:
tests/invalid_nodepend/errors_2.err_exp:
tests/invalid_nodepend/funcs_as_preds.err_exp:
tests/warnings/ambiguous_overloading.err_exp:
tests/warnings/save.err_exp:
tests/warnings/singleton_test.err_exp:
tests/warnings/unused_interface_import.err_exp:
    Update the expected outputs of these test cases to expect the new warning
    for unsorted import blocks in their source files.

tests/invalid/Mercury.options:
tests/invalid_nodepend/Mercury.options:
tests/warnings/Mercury.options:
    Execute those test cases with the warning enabled.

tests/invalid_nodepend/require_tailrec_invalid.m:
tests/invalid_nodepend/specified.m:
tests/recompilation/pragma_type_spec_r.m.1:
tests/recompilation/type_qual_re.m.1:
tests/recompilation/type_qual_re_2.m.1:
tests/recompilation/type_spec_unname_var_r.m.1:
tests/recompilation/type_spec_unname_var_r_2.m.1:
tests/recompilation/type_spec_unname_var_r_2.m.2:
tests/recompilation/unchanged_pred_nr.m.1:
tests/recompilation/with_type_re.m.1:
    Sort the import blocks in these test cases, and where relevant,
    import only one module per line.

tests/recompilation/with_type_re.err_exp.2:
    Expect updated line numbers after splitting a line that imported
    two modules.

tests/warnings/unsorted_import_blocks.{m,err_exp}:
    New test case to exercise one nontrivial part of the sortedness check,
    numerical non-sortedness. (The other affected test cases already exercise
    all the other parts.)

tests/warnings/Mmakefile:
    Enable the new test case.
2025-01-21 19:19:33 +11:00
Zoltan Somogyi
a19bcaaed5 Updates to programming style in the library.
library/bt_array.m:
    Reorder the arguments of the resize and shrink predicates
    to make them easier to use with state variables.

tests/general/array_test.m:
    Update the test calls to these two predicates.

library/version_array2d.m:
    Rewrite part of this module using a programming style that includes
    variable names that are longer than one character :-(. In the absence
    of comprehensive, or even basic, test cases, leave the rest using
    the old style.

    Add a non-field-syntax lookup operation.

    Mark the site of a probable bug.

library/version_bitmap.m:
    Add non-field-syntax versions of the get_bit and set_bit operations.

NEWS.md:
    Announce the reordering and the new predicates above.

library/getopt.m:
library/getopt_io.m:
    Apply to getopt_io.m an update that was previously applied to getopt.m,
    even though getopt.m is now computed from getopt_io.m.

library/array2d.m:
library/bit_buffer.m:
library/bit_buffer.read.m:
library/bit_buffer.write.m:
library/bitmap.m:
library/cord.m:
library/edit_distance.m:
library/edit_seq.m:
library/fat_sparse_bitset.m:
library/fatter_sparse_bitset.m:
library/list.m:
library/one_or_more.m:
library/pair.m:
library/ra_list.m:
library/rbtree.m:
library/set_bbbtree.m:
library/set_ctree234.m:
library/set_ordlist.m:
library/set_tree234.m:
library/set_unordlist.m:
library/solutions.m:
library/sparse_bitset.m:
library/test_bitset.m:
library/thread.barrier.m:
library/thread.m:
library/thread.semaphore.m:
library/time.m:
library/tree_bitset.m:
library/version_array.m:
library/version_hash_table.m:
library/version_store.m:
    General updates to style, the main ones being the following.

    Using standard names for type variables:

    - K and V for key and value types in map-like structures
    - A to F for types of accumulators
    - T for most everything else, possibly with a numeric suffix
      to distinguish two separate types that nevertheless play
      similar roles.

    (I left descriptive type var names such as Stream and Store unchanged.)

    Adding or expanding descriptions of exported predicates and functions.

    Declaring and defining field syntax getters and setters without using ^,
    while keeping the use of field syntax, including ^, in the operations'
    descriptions.

    Defining field syntax operations operations in terms of the
    non-field-syntax versions, not vice versa.

    Defining function versions of operations in terms of the predicate
    versions, not vice versa.
2024-12-29 20:09:09 +11:00
Zoltan Somogyi
22b058bb34 Make two warnings standard.
STANDARD_MCFLAGS:
    Make --warn-dead-preds and --warn-implicit-stream-calls the defaults.
    Previously, these were the defaults in some directories, but not all.

browser/MDB_FLAGS.in:
compiler/COMP_FLAGS.in:
deep_profiler/DEEP_FLAGS.in:
grade_lib/GRADE_LIB_FLAGS.in:
library/LIB_FLAGS.in:
mdbcomp/MDBCOMP_FLAGS.in:
mfilterjavac/MFILTERJAVAC_FLAGS.in:
profiler/PROF_FLAGS.in:
slice/SLICE_FLAGS.in:
ssdb/SSDB_FLAGS.in:
    Delete option settings that are now in STANDARD_MCFLAGS.

deep_profiler/autopar_calc_overlap.m:
deep_profiler/autopar_find_best_par.m:
deep_profiler/autopar_search_callgraph.m:
deep_profiler/coverage.m:
deep_profiler/mdprof_create_feedback.m:
deep_profiler/mdprof_test.m:
deep_profiler/measurements.m:
deep_profiler/program_representation_utils.m:
deep_profiler/read_profile.m:
deep_profiler/startup.m:
deep_profiler/var_use_analysis.m:
profiler/generate_output.m:
profiler/process_file.m:
profiler/snapshots.m:
    Avoid warnings about dead code by

    - deleting it (if it is trivial recreate if ever needed again,
      or is obviously never going to be needed again,

    - commenting out the dead predicates, if the module concerned already
      has such code, or

    - adding consider_used pragmas for the dead predicates.

grade_lib/choose_grade.m:
grade_lib/grade_setup.m:
grade_lib/grade_solver.m:
grade_lib/test_grades.m:
grade_lib/try_all_grade_structs.m:
library/edit_distance.m:
    Use explicit streams.

deep_profiler/canonical.m:
deep_profiler/Mercury.options:
    Disable --warn-dead-preds for the canonical module, which was
    never finished. Document this fact.

library/Mercury.options:
    Disable --warn-implicit-stream-calls for the modules that export
    predicates that do I/O to implicitly specified streams, since
    they cannot be fixed without breaking backwards compatibility.

ssdb/ssdb.m:
    Document the fact that this module requires nontrivial changes
    (storing the ids of the input/stream streams in the debugger state)
    to avoid warnings from --warn-implicit-stream-calls.

    Document why --warn-dead-preds must be disabled for (the current code of)
    this module.

    Change a type from an equivalence type to a notag type, for additional
    type safety.

    Add some documentation.

    Delete a dead predicate.

ssdb/Mercury.options:
    Disable --warn-dead-preds and --warn-implicit-stream-calls for ssdb.m.
2024-11-10 02:24:18 +11:00
Zoltan Somogyi
3c19765ffb Put edit_distance.m's contents into top-down order. 2024-07-19 15:45:50 +02:00
Zoltan Somogyi
b6a43532a9 Improve some comments. 2024-07-19 14:52:31 +02:00
Julien Fischer
d07f3e4cc3 Fix double-up word.
library/edit_distance.m:
    As above.
2024-07-19 20:56:23 +10:00
Julien Fischer
4cd5c17f61 Fix more copyright notices ...
... and other minor fixes.

library/*.m:
library/LIB_FLAGS.in:
compiler/*.m:
mdbcomp/*.m:
    Fix and update copyright notices.

    Fix spelling.

    Delete trailing whitespace.
2024-02-20 17:18:52 +11:00
Julien Fischer
f5e71b1e90 Fix copyright notices in recently modified files.
compiler/*.m:
library/*.m:
mdbcomp/*.m:
runtime/*.[ch]:
    As above.

    Fix spelling in some spots.
2024-02-20 15:09:17 +11:00
Zoltan Somogyi
4b3b6a9ed8 Add find_best_close_enough_seqs.
library/edit_distance.m:
    Add the above predicate, and its specialized version
    find_best_close_enough_strings, which allow their callers to specify
    a edit distance beyond which the results would not be useful.

compiler/error_spec.m:
    Use the new functionality to restrict the set of "close enough"
    candidates to those that replace at most half the characters in the name
    for which we are generating a "did you mean" message.
2024-01-26 15:34:16 +11:00
Zoltan Somogyi
a51735cd0d Speed up find_closest_seqs.
library/edit_distance.m:
    When find_closest_seqs computes the distance between the query sequence
    and a second or later candidate sequence, it already knows the minimum
    distance it has seen so far, and it knows that it will throw away
    any distance that exceeds this minimum. Allow it to tell find_edit_distance
    to stop computing the distance once it is certain that it will be
    thrown away.

    This increases the cost of computing each row slightly (since we now
    compute the minimum cost in each row), but it reduces the number of rows
    we have to compute, and in typical uses cases of find_closest_seqs,
    we expect the second effect to be dominant.

    In situations in which the caller invokes find_edit_distance directly,
    not through find_closest_seqs, we get a slight slowdown, since the second
    effect cannot happen.
2024-01-26 13:04:30 +11:00
Zoltan Somogyi
4a72158517 Speed up find_edit_distance.
library/edit_distance.m:
    Speed up the find_edit_distance predicate by

    - changing it to operate on arrays instead of maps, and
    - reusing the *same* three arrays over and over.
2024-01-25 23:30:52 +11:00
Zoltan Somogyi
565c65a39a Add find_closest_strings. 2023-09-26 02:41:58 +10:00
Zoltan Somogyi
c69b7e4b9a Add "did you mean ..." to undef pred reports.
compiler/typecheck_error_undef.m:
    If we are reporting an error for a reference to an undefined predicate,
    check whether any predicates exist whose names are "close enough"
    to the name of the referenced predicate, and if yes, add to the
    error message a line containing "(Did you mean x, y or z?)".

    (Doing the same for references to undefined functions is future work.
    The two are separate because things that look like function references
    can also refer to e.g. data constructors.)

library/edit_distance.m:
    Add this new module to implement the "close enough" check.
    This new module is similar to the existing edit_seq.m module,
    but it is designed to serve different requirements, and it seems to me
    to be far from trivial to write code to meet both sets of requirements
    at once.

library/library.m:
library/MODULES_DOC:
    Include the new module in the standard library.

NEWS.md:
    Announce the new library module.

tests/hard_coded/edit_distance_test_closest.{m,exp}:
tests/hard_coded/edit_distance_test_cost.{m,exp}:
    Two new test cases, each of which tests one of the two predicates
    exported by the new library module.

tests/hard_coded/Mmakefile:
    Enable the new test cases.

tests/invalid/qual_basic_test2.err_exp:
tests/invalid/types2.err_exp:
tests/invalid/undef_symbol.err_exp:
tests/invalid_submodules/undef_mod_qual.err_exp:
    Expect the new "did you mean" additions to error messages.
2023-09-26 00:56:19 +10:00