Commit Graph

23 Commits

Author SHA1 Message Date
Julien Fischer
0f0df8bd03 Fix spelling.
library/stream:
    As above.

library/term_io.m:
    Bump year in copyright notice.
2023-04-07 16:36:08 +10:00
Zoltan Somogyi
5c8e430c78 Improve formatting. 2023-04-07 00:42:51 +10:00
Julien Fischer
e7d28ff90f Update copyright notices in stdlib.
library/*.m:
    As above.
2022-06-07 21:51:03 +10:00
Zoltan Somogyi
8ff61f8a4b Delete quotes from `VarNames' in stdlib comments.
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.
2022-03-07 11:49:00 +11:00
Zoltan Somogyi
b19939be07 Improve some comments. 2021-10-11 05:48:25 +11:00
Julien Fischer
ba5fe38ee7 Add unboxed_readers to the stream module.
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.
2020-04-20 17:49:06 +10:00
Julien Fischer
db6c1fbb5c Documentation fixes for the stream module.
library/stream.m:
    As above.
2020-04-13 15:25:30 +10:00
Julien Fischer
2417278340 Add seek with 64-bit offsets to seekable/2 type class.
library/stream.m:
     As above.

library/io.m:
     Update the seekable/2 instances for binary input and
     output streams.
2019-10-08 21:36:11 +11:00
Mark Brown
d465fa53cb Update the COPYING.LIB file and references to it.
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.
2018-06-09 17:43:12 +10:00
Peter Wang
0b36d737f8 Document what whitespace means to library predicates.
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.
2017-10-02 14:30:08 +11:00
Zoltan Somogyi
5057ab7e04 Use explicit streams in some library modules.
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.
2016-10-30 00:49:21 +11:00
Zoltan Somogyi
44f9f1f405 Convert (C->T;E) to (if C then T else E). 2015-12-01 07:58:07 +11:00
Zoltan Somogyi
7f9791aa26 Standardize divider line lengths in the library.
library/*.m:
    As above.

tool/stdlines:
    A new shell script to do the job.
2014-11-23 22:05:34 +11:00
Julien Fischer
bed96b93ff Avoid module qualification in library interfaces where possible.
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.
2014-10-10 15:08:24 +11:00
Zoltan Somogyi
1c3bc03415 Make the system compiler with --warn-unused-imports.
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.
2010-12-30 11:18:04 +00:00
Simon Taylor
d73e2187fb Add bit_buffers to the standard library. A bit_buffer
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.
2007-05-30 02:47:10 +00:00
Julien Fischer
e316ecfa31 Fix a typo in a comment.
Estimated hours taken: 0
Branches: main

Fix a typo in a comment.

library/stream.m.:
	s/stream/streams/ in a spot.
2007-05-22 06:25:03 +00:00
Julien Fischer
35424dcd58 Make the stream error type specific to each reader, not specific to an entire
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.
2007-04-23 02:44:01 +00:00
Julien Fischer
3c65beae14 s/streams/stream/ in a spot.
library/stream.m:
	s/streams/stream/ in a spot.
2007-03-06 12:43:34 +00:00
Julien Fischer
2205625005 Fix some minor departures from our coding standard.
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.
2007-01-09 13:03:38 +00:00
Simon Taylor
f1275fa6e8 Implement io.write for arbitrary streams. With type specialization
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.
2006-12-21 11:11:37 +00:00
Julien Fischer
ae375664b9 Add some new utility predicates for use with streams.
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.
2006-11-09 00:47:27 +00:00
Julien Fischer
9fa6c7eb9c Add a new module to the standard library that provides generic stream
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.
2006-10-26 05:13:53 +00:00