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/stream.m:
Add a new type of reader, unboxed_reader. These provide a 'get'
operation that does not need to box its output in the non-error case.
library/io.m:
Add an unboxed_reader instance for text_input_streams and chars.
NEWS:
Announce the addition.
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/char.m:
Present list of whitespace characters for char.whitespace
in tabular form.
library/io.m:
library/lexer.m:
library/pprint.m:
library/stream.m:
library/string.m:
Mention char.is_whitespace in the documentation of predicates which
use that definition of whitespace characters.
Module qualify some calls to char.is_whitespace for clarity.
library/backjump.m:
library/exception.m:
library/getopt_io.m:
library/psqueue.m:
library/set_ctree234.m:
library/set_tree234.m:
library/tree234.m:
Avoid using implicit streams.
library/io.m:
Add a version of the write_cc predicate that allows callers
to specify an explicit stream.
Fix what seems like an old bug in read_binary_file_as_bitmap: it was not
reading from the file at all.
Use explicit module qualification in some places to make the code more
readable.
library/table_statistics.m:
Add a version of the write_table_stats predicate that allows callers
to specify an explicit stream.
Avoid using implicit streams inside the module as well.
library/term_io.m:
Add versions of the predicates that read terms that allow callers
to specify an explicit stream.
Avoid using implicit streams inside the module as well.
library/parser.m:
Add module qualifications that are needed after the new addition of new
predicates to term_io.m.
library/stream.m:
library/stream.string_writer.m:
Fix style.
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: 2
Branches: main, release
Make the system compiler with --warn-unused-imports.
browser/*.m:
library/*.m:
compiler/*.m:
Remove unnecesary imports as flagged by --warn-unused-imports.
In some files, do some minor cleanup along the way.
Estimated hours taken: 90
Branches: main
NEWS:
library/bit_buffer.m:
library/bit_buffer.read.m:
library/bit_buffer.write.m:
Add bit_buffers to the standard library. A bit_buffer
provides a bit-oriented interface to byte streams.
These will be used as a base for write_binary and read_binary.
library/stream.m:
Add class which supports reading multiple items at once into
a store.
Clarify the blocking behaviour of `put' and `get'.
Document the behaviour of subsequent calls to `get'
after a call returns eof or an error.
library/bitmap.m:
Add a shorthand for `new(N, no)'.
Add `shrink_without_copying' to destructively shrink a bitmap
without copying the data.
Add a function `append_list' to condense a list of bitmaps.
Improve bounds error messages.
Clean up the handling of zero-length bit ranges.
Add type `bitmap.slice' to represent a segment of a bitmap,
and functions to create slices.
library/io.m:
Change the interface of io.read_bitmap to conform to
the stream.bulk_reader interface, by not returning the
bitmap inside the return code. The bitmap is still
valid (although maybe not completely filled) no matter
what result is returned.
Add io.read_binary_file_as_bitmap/N.
library/library.m:
Add recent additions to the list of library modules.
library/Mercury.options:
Use "+=" rather than "=" when setting target-specific
options to allow them to be added to be Mmake.params.
tests/hard_coded/Mmakefile:
tests/hard_coded/bit_buffer_test.m:
tests/hard_coded/bit_buffer_test.exp:
Test case.
tests/hard_coded/bitmap_test.m:
tests/hard_coded/bitmap_simple.m:
tests/hard_coded/bitmap_test.exp:
Update for change to io.read_bitmap.
Test bounds error messages.
Estimated hours taken: 0.5
Branches: main
Make the stream error type specific to each reader, not specific to an entire
input stream. This means that different readers attached to the same stream
can return different types of error; this is useful in the case where a
reader can return a partial result.
library/stream.m:
Change the definition of input streams so that they no longer include
parameter for the error type.
Introduce the error type as a parameter of the reader class.
This means that different readers attached to the same stream may
now have different error types. The error type is functionally
dependent upon the reader's handle and unit types.
library/io.m:
extras/net/tcp.m:
tests/valid/logged_stream.m:
Conform to the above change.
Estimated hours taken: 0.1
Branches: main
library/stream.m:
library/stream.string_writer.m:
Fix some minor departures from our coding standard.
Delete some duplicate imports.
Estimated hours taken: 25
Branches: main
Implement io.write for arbitrary streams. With type specialization
this is only slightly slower than the original.
library/stream.string_writer.m:
library/library.m:
A module containing predicates for writing to streams
which accept strings.
library/stream.m:
Move stream.format to stream.string_writer.m.
Add stream.put_list, which is like io.write_list.
library/io.m:
Move io.write and io.print to stream.string_writer.m.
library/term_io.m:
Add stream versions of predicates used by io.write.
library/ops.m:
Move io.adjust_priority_for_assoc to here (private
predicate used only by library modules).
Export ops.mercury_max_priority for use by
stream.string_writer.write.
Mmake.common.in:
compiler/modules.m:
compiler/mlds.m:
compiler/mlds_to_c.m:
compiler/mlds_to_java.m:
compiler/mlds_to_managed.m:
compiler/prog_util.m:
compiler/format_call.m:
mdbcomp/prim_data.m:
Allow sub-modules in the standard library.
compiler/polymorphism.m:
Fix a bug which caused tests/hard_coded/print_stream.m to
fail with this change. The wrong argument type_info would
be extracted from a typeclass_info if the constraints of the
typeclass-info were not all variables.
browser/browse.m:
tests/hard_coded/stream_format.m:
tests/hard_coded/test_injection.m:
tests/invalid/string_format_bad.m:
tests/invalid/string_format_unknown.m:
Updated for predicates moved between library modules.
util/mdemangle.c:
The demangler doesn't properly handle the arguments MR_DECL_LL*
and various other recently added macros for type specialized
procedures. It's still broken (it doesn't handle mode and label
suffixes properly), but the output is at least more readable.
Estimated hours taken: 2
Branches: main
Add some new utility predicates for use with streams.
library/stream.m:
Add the predicate stream.format/5, an analogue of io.format,
that writes formatted output using an arbitrary string writer.
Add a predicate stream.ignore_whitespace/4 that can be used
to skip past whitespace in a putback char reader stream.
library/Mercury.options:
Don't warn about unknown format calls in the stream module.
Unrelated change: remove a workaround that was put in place
before the addition of the `--no-warn-obsolete' option.
compiler/format_call.m:
Also analyse calls to stream.format/5.
tests/hard_coded/Mmakefile:
tests/hard_coded/stream_format.{m,exp}:
tests/hard_coded/stream_ignore_ws.{m,exp,data}:
Test stream.format/5 and stream.ignore_whitespace/3.
tests/invalid/string_format_bad.{m,exp}:
tests/invalid/string_format_unknown.{m,exp}:
Check that we emit messages for bad/unknown calls to stream.format/5.
Estimated hours taken: 30 (+ 15 by Ian) (+ unknown late last year)
Branches: main
Add a new module to the standard library that provides generic stream
handling via a family of typeclasses. This subsumes the functionality
provided by the existing stream library in extras and improves upon that
design in several ways.
This incarnation of streams is parameterized over the state that is
updated by the stream operations, i.e. it is no longer restricted to
just being the I/O state. Streams are also parameterized over the
type of the data being written to, or read from, them. This allows for
efficient implementations of operations like write_string, and also
allows the put and get methods for a single stream to be overloaded.
Subsequent diffs will extend the io module to make the standard file
streams instances of these typeclasses and convert things like the
pretty printer and term_to_xml to use them as well.
library/stream.m:
New file. This module defines the stream typeclasses.
library/library.m:
Include the new library module.