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.
Estimatd hours taken: 0.5
Branches: main
samples/*.m:
Use '.' as the module qualifier instead of '__'.
Use the new foreign language interface.
Fix minor formatting issues.
Use state variables for passing the I/O state.
Estimated hours taken: 1.0
Branches: main and 0.12
Bring some samples up to date with current coding standards.
samples/calculator.m
samples/calculator2.m
samples/cat.m
samples/e.m
samples/eliza.m
samples/expand_terms.m
samples/hello.m
samples/interpreter.m
samples/sort.m
samples/ultra_sub.m
Bring up to date with current coding standards.
Estimated hours taken: 1
Fix some problems in the samples.
samples/calculator.m:
Strip spaces from the input before using it.
I keep forgetting that spaces aren't allowed in the input
of this example, and I can only assume that new users get
confused over this.
samples/c_interface/c_calls_mercury/Mmakefile:
Use MLOBJS instead of MLLIBS for including .o files.
Add a missing dependency.
Remove an unnecessary dependency that MLOBJS takes care of.
samples/c_interface/mercury_calls_fortran/Mmakefile:
Use MLOBJS instead of MLLIBS for including .o files.
Use -lg2c instead of the old -lf2c for the fortran library.
(libf2c no longer exists)
Estimated hours taken: 0.1
samples/calculator.m:
samples/eliza.m:
samples/interpreter.m:
Add calls to `io__flush_output', so that the input and output
are interleaved properly when you run the programs with output
redirected to a pipe, e.g. "./calculator | tee logfile".