profiler/options.m:
Use io.write_prefixed_lines for writing the usage message.
Add -? as a synonym for --help.
samples/diff/options.m:
samples/mcowsay.m:
Use io.write_prefixed_lines for writing the usage messages.
extras/trailed_update/samples/interpreter.m:
samples/interpreter.m:
We have these two different versions of a pure Prolog interpreter
as examples of Mercury code. Reduce the number of unneeded points
of difference between them, by copying the better code at each such point
to the other file.
tests/debugger/interpreter.m:
This file is automatically copied from samples/interpreter.m.
tests/debugger/interpreter.exp:
Expect the changes caused by the update to the source file.
samples/c_interface/cplusplus_calls_mercury/Mmakefile:
samples/c_interface/mercury_calls_cplusplus/Mmakefile:
samples/c_interface/simpler_cplusplus_calls_mercury/Mmakefile:
As above.
samples/c_interface/*:
Replace left over references to the old c_header_code pragma.
Replace some uses of '__' as a module qualifier.
Replace tabs with spaces.
Add some missing words.
library/ops.m:
Instead of an op_table mapping a string to a list of one or more op_infos,
make it map the string to a single structure, the op_infos, which has
four slots, one each for infix, binary prefix, prefix and postfix
op information. This allows parsers and unparsers to go directly to
the kind of operator (e.g. infix or prefix) that they are interested in.
NEWS:
Announce the change.
compiler/parse_tree_out_term.m:
library/mercury_term_parser.m:
library/pretty_printer.m:
library/stream.string_writer.m:
library/string.to_string.m:
samples/calculator2.m:
tests/hard_coded/bug383.m:
Conform to the change. In several places, the new operator representation
allows the replacement of loops with direct lookups, and the replacement
of if-then-else chains with switches.
Add reminders about keeping two predicates in sync.
library/io.m:
Delete the set_io_table predicate, which did nothing and was never
called from anywhere, and the get_io_table predicate, which always
returned the same op_table. They were in io.m's interface, but in the
not-publicly-visible part of the interface.
library/ops.m:
Rename the lookup_op method to is_op.
Delete references to the predicates deleted from io.m.
NEWS:
Announce the lookup_op->is_op rename.
compiler/parse_tree_out_term.m:
library/mercury_term_parser.m:
library/string.to_string.m:
library/term_io.m:
samples/calculator2.m:
tests/hard_coded/bug383.m:
Conform to the lookup_op->is_op rename.
Replace calls to get_io_table with code that directly gets
the Mercury op table.
In parse_tree_out_term.m, call the predicates operating on the
Mercury op table directly, not through the op_table type class.
In mercury_term_parser.m, update some comments.
In term_io.m, use OpTable to refer to op_tables.
tests/hard_coded/stdlib_init.{m,exp}:
Don't test get_io_table.
NEWS:
Mention that we do no longer accept : as module name separator.
Improve wording.
extras/README.md:
Document the new old_library_modules directory.
library/ops.m:
Fix wording, and a dangling reference.
samples/calculator2.m:
Update to use the new ops.m.
Mercury inherited its original system of operator priorities from Prolog,
because during its initial development, we wanted to be able execute
the Mercury compiler using NU-Prolog and later SICStus Prolog.
That consideration has long been obsolete, and now we may fix the
design error that gifted Prolog with its counter-intuitive system
of operator priorities, in which higher *numerical* operator priorities
mean lower *actual* priorities. This diff does that.
library/ops.m:
Change the meaning of operator priorities, to make higher numerical
priorities mean also higher actual priorities.
This semantic change requires corresponding changes in any other module
that uses ops.m. To force this change to occur, change the type
representing priorities from being a synonym for a bare int to being
a notag wrapper around an uint.
The old "assoc" type had a misleading name, since it is related to
associativity but is not itself a representation of associativity.
Its two function symbols, which used to be just "x" and "y", meant that
the priority of an argument must be (respectively) greater than,
or greater than equal to, the priority of the operator. So rename
x to arg_gt, y to arg_ge, and assoc to arg_prio_gt_or_ge.
Rename the old adjust_priority_for_assoc predicate to min_priority_for_arg,
which better expresses its semantics. Turn it into a function, since
some of its users want it that way, and move its declaration to the
public part of the interface.
Add a method named tightest_op_priority to replace the use of 0
as a priority.
Rename the max_priority method as the loosest_op_priority method.
Add a method named universal_priority to replace the use of
max_priority + 1 as a priority.
Add a function to return the priority of the comma operator,
to allow other modules to stop hardcoding it.
Add operations for comparing priorities and for incrementing/decrementing
priorities.
Change the prefix on the names of the predicates that take op_infos
as inputs from "mercury_op_table_" to "op_infos_", since the old prefix
was misleading.
Add a note on an significant old problem with an exported type synonym.
library/mercury_term_parser.m:
Conform to the changes above.
Delete unnecessary module qualifiers, since they were just clutter.
Add "XXX OPS" to note further opportunities for improvement.
library/pprint.m:
Conform to the changes above.
Rename a function to avoid ambiguity.
library/pretty_printer.m:
library/stream.string_writer.m:
library/string.to_string.m:
library/term_io.m:
Conform to the changes above.
library/string.m:
Add a note on an significant old problem.
NEWS:
Announce the user-visible changes.
tests/hard_coded/bug383.m:
Update this test case to use the new system of operator priorities.
tests/hard_coded/term_io_test.{m,inp}:
Fix white space.
extras/old_library_modules/old_mercury_term_parser.m:
extras/old_library_modules/old_ops.m:
The old contents of the mercury_term_parser and ops modules,
in case anyone wants to continue using them instead of updating
their code to use their updated equivalents.
samples/calculator2.m:
Import the old versions of mercury_term_parser and ops.
samples/mcowsay.m:
A Mercury version of the cowsay program. It serves an more extended
example (but still small) example of how to write command line
utilities in Mercury.
samples/README.md:
Include the new sample.
samples/Mmakefile:
Include the new sample.
Put the list of sample programs in alphabetical order.
samples/c_interface/mercury_calls_fortran/Mmakefile:
g77 was replaced by gfortran in GCC 4.0, use the latter in
this example.
samples/c_interface/mercury_calls_fortran/fortran_main_int.m:
Replace a ':- pragma import' with an equivalent foreign_proc.
Describe the current gfortran name mangling scheme and delete
references to g77 command line options not supported by gfortran.
samples/c_interface/mercury_calls_fortran/mercury_main.m:
Replace tabs with spaces.
tests/general/interpreter.{m,inp,exp}:
tests/general/Mmakefile:
As above: delete this test case.
samples/interpreter.m:
Delete reference to the deleted test case.
tests/debugger/interpreter.m:
Delete reference to the deleted test case in this copy of
samples/interpreter.m.
tests/debugger/interpreter.exp:
tests/debugger/interpreter.exp2:
The last update of interpreter.exp was in 2003. The command we invoke
this test case with has changed several times since then, but none
of them have been reflected in interpreter.exp, so now there is no way
for it to be matched. This diff deletes interpreter.exp, and renames
the old interpreter.exp2 to become the new interpreter.exp.
tests/general/arithmetic.nl:
tests/general/interpreter.nl:
tests/general/string_test.nl:
Delete these relics of the time when we compared output generated
by Mercury to output generated by NU-Prolog, since NU-Prolog is long dead.
tests/general/arithmetic.m:
tests/general/string_test.m:
Update programming style, and factor out common code.
samples/interpreter.m:
Make this the primary copy of interpreter.m. Incorporate the improvements
from the other two versions in tests, and generalize them to be suitable
as a sample program.
tests/debugger/interpreter.m:
tests/general/interpreter.m:
Make these copies of the primary version.
tests/debugger/Mmakefile:
tests/general/Mmakefile:
Keep the tests copies of the primary version.
tests/general/interpreter.exp:
Expect an output now generated for parameter-less invocations.
samples/java_interface/short_example.m:
A Java version of the short example.
samples/java_interface/README.md:
Add an entry for the new example.
samples/c_interface/README.md:
samples/csharp_interface/README.md:
Fix wording.
samples/csharp_interface/README.md:
Add a README file for this subdirectory.
samples/java_interface/README:
Rename this file to README.md; convert its contents
to Markdown.
Convert the samples README file to Markdown. The aim is to improve the way
this file appears when viewed in GitHub.
Fix a number of small errors.
samples/README:
As above.
If we want to encourage people to read the sample programs
and learn Mercury programming from them, they should not be written
in an obsolete style.
samples/beer.m:
samples/calculator.m:
samples/calculator2.m:
samples/concurrency/midimon/midimon.m:
samples/diff/diff_out.m:
samples/e.m:
samples/eliza.m:
samples/muz/dict.m:
samples/muz/higher_order.m:
samples/muz/muz.m:
samples/muz/typecheck.m:
samples/muz/word.m:
samples/muz/zabstract.m:
samples/muz/zlogic.m:
samples/muz/zparser.m:
samples/muz/ztoken.m:
samples/muz/ztoken_io.m:
samples/muz/ztype.m:
samples/muz/ztype_op.m:
samples/rot13/rot13_concise.m:
samples/rot13/rot13_gustavo.m:
samples/rot13/rot13_juergen.m:
samples/rot13/rot13_ralph.m:
samples/rot13/rot13_verbose.m:
samples/solutions/all_solutions.m:
samples/solutions/n_solutions.m:
samples/solutions/one_solution.m:
samples/solutions/some_solutions.m:
samples/solver_types/eqneq.m:
samples/solver_types/sudoku.m:
samples/solver_types/test_eqneq.m:
Replace uses of __ as module qualifier with dot.
Replace (C->T;E) with (if C then T else E).
Use our usual indentation for if-then-elses and for switches.
Import one module per line. Put those imports into alphabetical order.
Replace many uses of DCGs with state variables, leaving DCGs
mostly just for parsing code.
Use predmode declarations where this helps.
Put predicates in top-down order where relevant.
Use io.format where this helps.
Do not put more than one predicate call on one line.
Put each function symbol in a du type on a separate line.
Put spaces after commas, around the bar in list syntax,
around arithmetic operators, and around minus signs used for pairs.
Replace tab indentation with four-space indentation.
Delete spaces at the ends of lines.
Replace two or more consecutive blank lines with one blank line.
Delete blank lines that do not help structure the code.
There are probably still some examples of old practices remaining;
I do not claim to have fixed them all.