Commit Graph

5 Commits

Author SHA1 Message Date
Zoltan Somogyi
a815cf45e6 Eliminate overuse of ^s in library/bitmap.m.
library/bitmap.m:
    Replace all uses of field access notation for things that are not
    structure fields with getter functions and setter predicates.
    Add the getter functions and setter predicates where they did not
    exist before. Unlike the old "field :=" functions, the new setter
    predicates lend themselves to state variable notation.

    Replace nested applications of functions with sequences of calls
    (usually a get/modify/set sequence) that is easier to read and
    understand, partly because it gives meaningful names to the
    intermediate values.

    Where an operation was available as both a function and a predicate,
    implement the function version in terms of the predicate version,
    as is our convention in the rest of the Mercury implementation,
    instead of vice versa.

    In a few cases, where implementing the function in terms of the predicate
    could lead to misleading exceptions (that refer to the name of the
    predicate, not the function, even when the user called the function),
    have two copies of the implementation that differ only in the
    text of the exception(s) being thrown.

NEWS:
    Document the added exported functions and predicates.

tests/hard_coded/bitmap_empty.m:
    Replace io.write/io.nl sequences with io.write_line, including
    one case where the io.nl was missing :-(

    Fix misleading indentation.
2022-01-01 14:10:03 +11:00
Zoltan Somogyi
4865f11503 Update programming style. 2020-10-04 13:20:42 +11:00
Zoltan Somogyi
33eb3028f5 Clean up the tests in half the test directories.
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.
2015-02-14 20:14:03 +11:00
Julien Fischer
92ddfdcf11 Delete obsolete procedures and modules from the standard library.
library/array.m:
library/array2d.m:
library/bitmap.m:
library/store.m:
library/thread.semaphore.m:
library/version_array2d.m:
library/version_bitmap.m:
library/version_hash_table.m:
library/version_store.m:
	Delete predicates that were deprecated in Mercury 13.05 and before.

library/version_array.m
	Delete the deprecated function new/2.

	Deprecate unsafe_new/2	and unsafe_init/2 to replace it.
	(We had overlooked this previously.)

library/string.m:
	Delete the deprecated function set_char_char/3.
	(We will leave the other deprecated procedures in this module
	for at least another release.)

library/svlist.m:
library/svpqueue.m:
library/svstack.m:
	Delete these modules: they were only ever needed as a transitional
	mechanism.

library/library.m:
	Conform to the above changes.

doc/Mmakefile:
	Unrelated change: delete references to files that have been
	deleted since we moved to git.

tests/hard_coded/*/*.m
tests/tabling/*.m:
	Update test cases where they made use of predicates that have
	now been deleted from the standard library.
2013-05-16 17:50:15 +10:00
Peter Wang
a59a8bbe1d Fix bitmap predicates which did not work correctly with empty bitmaps.
Branches: main

Fix bitmap predicates which did not work correctly with empty bitmaps.

Note that `bitmap.to_string' now returns "<0:>" for an empty bitmap instead
of "<0:00>".

library/bitmap.m:
        Add `in_range_rexcl' to check an index is in the range [0, num_bits).

        Fix bounds checks on empty bitmaps in `^ bits' and `copy_bytes'.

        Simplify other bounds checks using `in_range_rexcl'.

        Make `byte_index_for_bit' return -1 if its argument is negative,
        instead of 0.  `byte_index_for_bit(NumBits - 1)' is used to get the
        last byte index, so now loops over empty bitmaps will stop immediately
        as the initial index must be greater than -1.

        Make some code neater.

tests/hard_coded/Mmakefile:
tests/hard_coded/bitmap_empty.exp:
tests/hard_coded/bitmap_empty.m:
        Add a test case.

NEWS:
        Mention changed behaviour of `bitmap.to_string'.
2010-03-02 00:32:37 +00:00