library/*.m:
Specifically, delete any predicates and functions whose `pragma obsolete'
dates from 2018 or before. Keep the ones that were obsoleted
only this year or last year.
NEWS:
Announce the changes.
tests/debugger/io_tab_goto.m:
tests/debugger/tabled_read.m:
tests/declarative_debugger/io_stream_test.m:
tests/declarative_debugger/tabled_read_decl.m:
tests/declarative_debugger/tabled_read_decl_goto.m:
tests/general/array_test.m:
tests/hard_coded/mutable_init_impure.m:
tests/hard_coded/remove_file.m:
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 references to predicates and functions that this diff deletes
with their suggested replacements.
In several test cases, bring the programming style up to date.
tests/hard_coded/shift_test.{m,exp}:
Most of this test case tested the now-deleted legacy shift operations.
Replace these with tests of their non-legacy versions, including
testing for the expected exceptions.
tests/hard_coded/shift_test.{m,exp}:
Don't pass --no-warn-obsolete when compiling shift_test.m anymore.
library/thread.mvar.m:
Document actual behaviour of mvar.try_take and mvar.try_read:
both may return `no' even if the mvar was not empty.
Clarify behaviour of mvar.read.
NEWS:
Announce change.
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.
If a module has two or more import_module or use_module declarations
for the same module, (typically, but not always, one being in its interface
and one in its implementation), generate an informational message about
each redundant declaration if --warn-unused-imports is enabled.
compiler/hlds_module.m:
We used to record the set of imported/used modules, and the set of
modules imported/used in the interface of the current module. However,
these sets
- did not record the distinction between imports and uses;
- did not allow distinction between single and multiple imports/uses;
- did not record the locations of the imports/uses.
The first distinction was needed only by module_qual.m, which *did*
pay attention to it; the other two were not needed at all.
To generate messages for imports/uses shadowing other imports/uses,
we need all three, so change the data structure storing such information
for *direct* imports to one that records all three of the above kinds
of information. (For imports made by read-in interface and optimization
files, the old set of modules approach is fine, and this diff leaves
the set of thus *indirectly* imported module names alone.)
compiler/unused_imports.m:
Use the extra information now available to generate a
severity_informational message about any import or use that is made
redundant by an earlier, more general import or use.
Fix two bugs in the code that generated warnings for just plain unused
modules.
(1) It did not consider that a use of the builtin type char justified
an import of char.m, but without that import, the type is not visible.
(2) It scanned cons_ids in goals in procedure bodies, but did not scan
cons_ids that have been put into the const_struct_db. (I did not update
the code here when I added the const_struct_db.)
Also, add a (hopefully temporary) workaround for a bug in
make_hlds_passes.m, which is noted below.
However, there are at least three problems that prevent us from enabling
--warn-unused-imports by default.
(1) In some places, the import of a module is used only by clauses for
a predicate that also has foreign procs. When compiled in a grade that
selects one of those foreign_procs as the implementation of the predicate,
the clauses are discarded *without* being added to the HLDS at all.
This leads unused_imports.m to generate an uncalled-for warning in such
cases. To fix this, we would need to preserve the Mercury clauses for
*all* predicates, even those with foreign procs, and do all the semantic
checks on them before throwing them away. (I tried to do this once, and
failed, but the task should be easier after the item list change.)
(2) We have two pieces of code to generate import warnings. The one in
unused_imports.m operates on the HLDS after type and mode checking,
while module_qual.m operates on the parse tree before the creation of
the HLDS. The former is more powerful, since it knows e.g. what types and
modes are used in the bodies of predicates, and hence can generate warnings
about an import being unused *anywhere* in a module, as opposed to just
unused in its interface.
If --warn-unused-imports is enabled, we will get two separate set of
reports about an interface import being unused in the interface,
*unless* we get a type or mode error, in which case unused_imports.m
won't be invoked. But in case we do get such errors, we don't want to
throw away the warnings from module_qual.m. We could store them and
throw them away only after we know we won't need them, or just get
the two modules to generate identical error_specs for each warning,
so that the sort_and_remove_dups of the error specs will do the
throwing away for us for free, if we get that far.
(3) The valid/bug100.m test case was added as a regression test for a bug
that was fixed in module_qual.m. However the bug is still present in
unused_imports.m.
compiler/make_hlds_passes.m:
Give hlds_module.m the extra information it now needs for each item_avail.
Add an XXX for a bug that cannot be fixed right now: the setting of
the status of abstract instances to abstract_imported. (The "abstract"
part is correct; the "imported" part may not be.)
compiler/intermod.m:
compiler/try_expand.m:
compiler/xml_documentation.m:
Conform to the change in hlds_module.m.
compiler/module_qual.m:
Update the documentation of the relationship of this module
with unused_imports.m.
compiler/hlds_data.m:
Document a problem with the status of instance definitions.
compiler/hlds_out_module.m:
Update the code that prints out the module_info to conform to the change
to hlds_module.m.
Print status information about instances, which was needed to diagnose
one of the bugs in unused_imports.m. Format the output for instances
nicer.
compiler/prog_item.m:
Add a convenience predicate.
compiler/prog_data.m:
Remove a type synonym that makes things harder to understand, not easier.
compiler/modules.m:
Delete an XXX that asks for the feature this diff implements.
Add another XXX about how that feature could be improved.
compiler/Mercury.options.m:
Add some more modules to the list of modules on which the compiler
should be invoked with --no-warn-unused-imports.
compiler/*.m:
library/*.m:
mdbcomp/*.m:
browser/*.m:
deep_profiler/*.m:
mfilterjavac/*.m:
Delete unneeded imports. Many of these shadow other imports, and some
are just plain unneeded, as shown by --warn-unused-imports. In a few
modules, there were a *lot* of unneeded imports, but most had just
one or two.
In a few cases, removing an import from a module, because it *itself*
does not need it, required adding that same import to those of its
submodules which *do* need it.
In a few cases, conform to other changes above.
tests/invalid/Mercury.options:
Test the generation of messages about import shadowing on the existing
import_in_parent.m test case (although it was also tested very thoroughly
when giving me the information needed for the deletion of all the
unneeded imports above).
tests/*/*.{m,*exp}:
Delete unneeded imports, and update any expected error messages
to expect the now-smaller line numbers.
This change renames the init/0 function in thread.mvar.m to impure_init/0;
deprecating the old function. This makss this module more consistent with
thread.semaphore.m.
Remove the "mvar." prefix where it is unnecessary.
Add %----% separators between some definitions in the implementation
section.
library/thread.mvar.m:
As above.
library/library.m:
library/thread.future.m:
library/thread.m:
Add new future standard library module.
NEWS:
Announce the new addition.
library/thread.semaphore.m:
Add an impure interface to thread.semaphore.m. Semaphores are used to
implement our other concurrency primitives and an impure interface can
often be useful to implement things such as futures, which don't require
IO state threading. The impure interface predicate names are prefixed
with "impure_".
library/thread.semaphore.m:
NEWS:
Deprecate the impure init/1 function.
library/thread.mvar.m:
Conform to changes in semaphore.m.
benchmarks/progs/mandelbrot/mandelbrot.m:
Add future example to mandelbrot benchmark.
Even after "taking" a value out of an mvar, the reference to the value
actually still remained. This may lead to higher than expected memory
usage.
(Aside: putting a dummy value into an mvar is a bad idea and unsolved by
this change. In low-level C grades whatever value happened to be in the
register for the value argument in the mvar.put call will be placed into
the mvar, and it might point to some large value which is otherwise
collectable.)
library/thread.mvar.m:
Make mvar.take and mvar.try_take clear the underlying mutvar
after retrieving the value.
library/mutvar.m:
Add clear_mutvar in support.
Branches: main, 11.07
Allow mutable variables to be initialised by impure functions.
Also fix bug #223. Make thread.semaphore.init/1 and thread.mvar.init/1
impure, as they should be. They were introduced to be used as mutable
initialisers, which led to the oversight of making them pure.
compiler/make_hlds_passes.m:
compiler/prog_mutable.m:
Modify the generated mutable initialisation predicates such that the
initial value may be the return value of a impure function call.
compiler/purity.m:
Ignore warnings about unnecessary impure annotations on goals in
generated mutable predicates. These would now appear when
a mutable is initialised by a call to a pure function, or
by a constant.
doc/reference_manual.texi:
NEWS:
Document the language change.
library/thread.mvar.m:
library/thread.semaphore.m:
Make thread.semaphore.init/1 and thread.mvar.init/1 impure.
tests/hard_coded/Mmakefile:
tests/hard_coded/mutable_init_impure.exp:
tests/hard_coded/mutable_init_impure.m:
Add test case.
Branches: main, 11.07
library/thread.mvar.m:
Add two operations: mvar.read, mvar.try_put.
Use `promise_pure' scopes instead of pragmas.
NEWS:
Announce the additions.
Branches: main, 11.07
library/thread.mvar.m:
Add function version of `mvar.init', which is useful as a mutable
initialiser.
NEWS:
Announce the addition.
Branches: main
Improve consistency amongst the standard library modules.
library/array2d.m:
library/bitmap.m:
library/hash_table.m:
library/store.m:
library/thread.semaphore.m:
library/version_array.m:
library/version_array2d.m:
library/version_bitmap.m:
library/version_hash_table.m:
library/version_store.m:
Use the name "init" for predicates and functions that create new empty
data structures instead of the name "new". (The majority of standard
library modules already use the former.)
Mark the "new" versions as obsolete.
library/bit_buffer.read.m:
library/bit_buffer.write.m:
library/io.m:
library/thread.mvar.m:
browser/declarative_execution.m:
compiler/make.m:
compiler/make.program_target.m:
ssdb/ssdb.m:
Conform to the above changes.
NEWS:
Announce the above changes.
Branches: main
Add predicates from MC's versions of the concurrency modules.
library/thread.channel.m:
Add channel.try_take/4, a non-blocking version of channel.take/4.
library/thread.mvar.m:
Add mvar.try_take/4, a non-blocking version of mvar.take/4.
NEWS:
Announce the additions.
Branches: main
Move more of the concurrency related modules from extras into the standard
library.
library/Mercury.options:
library/library.m:
library/thread.m:
library/thread.channel.m:
library/thread.mvar.m:
library/thread.semaphore.m:
Move the concurrency-related modules `channel', `mvar' and
`semaphore' from extras/concurrency into the standard library.
Make thread.mvar use the standard library module mutvar instead of
providing its own implementation of the same thing.
Replace "ME_" prefixes by "ML_".
library/mutvar.m:
Add predicate `new_mutvar0' which is like `new_mutvar' but does not
require an initial value for the mutvar. This is needed for
thread.mvar.
Define `new_mutvar' in terms of `new_mutvar0' and `set_mutvar'.
runtime/mercury_thread.h:
Make the MR_WAIT macro expand to "(0)" when MR_THREAD_SAFE is not
defined, so it can be used in an expression context. Zero is the
success code for pthread_cond_wait.
extras/concurrency/channel.m:
extras/concurrency/mvar.m:
extras/concurrency/semaphore.m:
Remove these modules.
extras/concurrency/Mercury.options:
extras/concurrency/concurrency.m:
Delete lines pertaining to removed modules.
extras/concurrency/philo.m:
extras/concurrency/philo2.m:
extras/concurrency/philo3.m:
Update to use the standard library modules.
NEWS:
Announce the change.