Commit Graph

3 Commits

Author SHA1 Message Date
Peter Wang
3621cfa650 Delete deprecated substring predicates and functions.
library/string.m:
    Delete long-deprecated substring/3 function and substring/4 predicate.
    The newly introduced `string_piece' type has a substring/3 data
    constructor which takes (start, end) offsets into the base string,
    whereas the function and predicate take (start, count) arguments.
    To reduce potential confusion, delete the deprecated function and
    predicate.

    Delete other deprecated substring predicates and functions as well.

tests/general/Mercury.options:
tests/general/string_foldl_substring.exp:
tests/general/string_foldl_substring.m:
tests/general/string_foldr_substring.exp:
tests/general/string_foldr_substring.m:
tests/hard_coded/Mercury.options:
tests/hard_coded/string_substring.m:
    Delete tests for deprecated predicates.

tests/tabling/mercury_java_parser_dead_proc_elim_bug.m:
tests/tabling/mercury_java_parser_dead_proc_elim_bug2.m:
tests/valid/mercury_java_parser_follow_code_bug.m:
    Replace calls to unsafe_substring with unsafe_between.

NEWS:
    Announce the changes.
2019-11-08 14:25:23 +11:00
Peter Wang
b1af59cb29 Deprecate string.substring, string.foldl_substring, etc. in favour of
Branches: main

Deprecate string.substring, string.foldl_substring, etc. in favour of
new procedures named string.between, string.foldl_between, etc.
The "between" procedures take a pair of [Start, End) endpoints instead
of Start, Count arguments.  The reasons for this change are:

- the "between" procedures are more convenient

- "between" should be unambiguous.  You can guess that it takes an End
  argument instead of a Count argument without looking up the manual.

- Count arguments necessarily counted code units, but when working with
  non-ASCII strings, almost the only way that the values would be arrived at
  is by substracting one end point from another.

- it paves the way for a potential change to replace string offsets with an
  abstract type.  We cannot do that if users regularly have to perform a
  subtraction between two offsets.

library/string.m:
	Add string.foldl_between, string.foldl2_between,
	string.foldr_between, string.between.

	Deprecate the old substring names.

	Replace string.substring_by_codepoint by string.between_codepoints.

compiler/elds_to_erlang.m:
compiler/error_util.m:
compiler/rbmm.live_variable_analysis.m:
compiler/timestamp.m:
extras/posix/samples/mdprof_cgid.m:
library/bitmap.m:
library/integer.m:
library/lexer.m:
library/parsing_utils.m:
mdbcomp/trace_counts.m:
profiler/demangle.m:
	Conform to changes.

tests/general/Mercury.options:
tests/general/string_foldl_substring.exp:
tests/general/string_foldl_substring.m:
tests/general/string_foldr_substring.exp:
tests/general/string_foldr_substring.m:
tests/hard_coded/Mercury.options:
tests/hard_coded/string_substring.m:
	Test both between and substring procedures.

tests/hard_coded/string_codepoint.exp:
tests/hard_coded/string_codepoint.exp2:
tests/hard_coded/string_codepoint.m:
	Update names in test outputs.

NEWS:
	Announce the change.
2011-06-15 01:05:34 +00:00
Ralph Becket
6ce7742051 Added.
Estimated hours taken: 0.5
Branches: main

tests/general/string_foldr_substring.m:
tests/general/string_foldr_substring.exp:
	Added.

tests/general/Mmakefile:
	Include string_foldr_substring test.
2002-10-28 06:06:08 +00:00