Files
mercury/samples
Julien Fischer 551574ea62 Remove support for automatic initialisation of solver types from the language.
Estimated hours taken: 10
Branches: main

Remove support for automatic initialisation of solver types from the language.
This is being done because:

* the current implementation of automatic initialisation means we cannot
  support polymorphic solver types, e.g. you cannot have the type foo(bar)
  where:
  		:- solver type foo(T).
		:- solver type bar.

* the current initialisation strategy is fairly ad-hoc anyway; in particular
  it has a tendency to unnecessarily change the determinism of procedures.

* mode error messages are often quite poor because of the interaction between
  automatic initialisation and impure code.

* automatic initialisation is not used in practice.  All of the
  G12 solver libraries that use solver types recommend explicitly
  initialising solver variables.

This change removes support for automatic solver initialisation from the
language.  The code for supporting it remains in the implementation, but
it is now dependent upon the developer-only `--solver-type-auto-init'
option.

As a transitional measure the compiler will still accept
`initialisation is ...' attributes in solver type definitions even when
`--no-solver-type-auto-init' is enabled.  After this change has bootstrapped,
and the relevant updates have been made to the G12 solver libraries, this
will be changed so that `initialisation is ...' attributes are considered
a syntax error unless `--solver-type-auto-init' is enabled.

doc/reference_manual.texi:
	Document that solver type definitions no longer allow initialisation
	predicates to be supplied.  (The section documenting initialisation
	predicates has been commented out rather than deleted since the
	implementation of automatic initialisation still exists.)

	Remove the section documenting the restrictions on polymorphic
	solver types.  These restrictions no longer apply in the absence
	of automatic initialisation.

compiler/options.m:
	Add a new developer-only option, `--solver-type-auto-init', that
	controls whether automatic initialisation of solver variables is
	allowed (for those solver types that have initialisation predicates
	specified.)

compiler/prog_data.m:
	Add a type that represents whether a solver type allows automatic
	initialisation or not.

	Extend the solver_type_details structure to allow initialisation
	predicates to be optional.

compiler/prog_io.m:
	Allow initialisation predicates to be optional in solver type
	definitions.

compiler/modes.m:
compiler/modecheck_call.m:
compiler/modecheck_unify.m:
	Only insert calls to solver type initialisation predicates if
	the solver type has an initialisation predicate and the
	developer-only option `--solver-type-auto-init' is enabled.

compiler/unify_proc.m:
	Handle the situation where a solver type does not have an
	initialise predicate.

compiler/add_special_pred.m:
	Only add initialisation special predicates for those solver
	types whose definition provides an initialisation predicate.

compiler/mode_info.m:
	Add a utility predicate that tests whether the support for
	automatic solver type initialisation is enabled.

compiler/type_util.m:
	Add a predicate that tests whether a type is a solver type
	that supports automatic initialisation.

	Add an XXX comment about such types and abstract equivalence
	types.

compiler/mercury_to_mercury.m:
	Conform to the above changes.

compiler/special_pred.m:
	Fix some typos.

samples/solver_types/eqneq.m:
	Delete the `initialisation is ...' from the definition of the solver
	type eqneq/1.

tests/hard_coded/Mercury.options:
	Enable `--solver-type-auto-init' for the solver_construction_init_test
	test.

tests/hard_coded/solver_build_call.m:
tests/invalid/any_pass_as_ground.m:
	Don't use automatic solver variable initialisation in these
	test cases.

tests/invalid/partial_implied_mode.err_exp:
	Conform to the above changes in the mode analyser.

tests/valid/Mercury.options:
	Compile some tests cases with `--solver-type-auto-init' enabled.
2007-10-31 04:27:29 +00:00
..
2007-07-16 11:45:23 +00:00
2007-07-16 11:37:05 +00:00

This directory contains some example Mercury programs.

hello.m			"Hello World" in Mercury.

cat.m                   An implementation of a simple version of the
			standard UNIX filter `cat', which just copies
			its input files or the standard input stream to
			the standard output stream.

sort.m                  An implementation of a simple version of the
			standard UNIX filter `sort', which reads lines
			from its input files or the standard input
			stream, sorts them, and then writes the result
			to the standard output stream.

calculator.m            A simple four-function arithmetic calculator,
			with a parser written using the Definite Clause
			Grammar notation.

calculator2.m		A simple four-function arithmetic calculator,
			which uses the parser module in the standard
			library with a user-defined operator precedence
			table.

committed_choice.m	An example illustrating committed-choice
			nondeterminism in Mercury.

interpreter.m		An simple interpreter for definite logic programs.
			A demonstration of meta-programming in Mercury.

expand_terms.m		Another example meta-program, showing how to
			emulate Prolog's `expand_term' mechanism.

e.m			A small program which calculates the base of
			natural logarithms to however many digits you
			choose.  It illustrates one way to achieve
			lazy evaluation in Mercury.

Mmakefile		The file used by `mmake', the Mercury Make program,
			to build the programs in this directory.

The `solutions' sub-directory contains some examples of the use of
nondeterminism, showing how a Mercury program can compute 
	- one solution,
	- all solutions, or
	- some solutions (determined by a user-specified criteria)
for a query which has more than one logically correct answer.

There are also some sub-directories which contain examples of multi-module
Mercury programs:

diff                    This directory contains an implementation of a
			simple version of the standard UNIX utility
			`diff', which prints the differences between
			two files.

c_interface		This directory contains some examples of mixed
			Mercury/C/C++/Fortran programs using the C interface.

rot13			This directory contains a few implementations of
			rot-13 encoding.

muz			This directory contains a syntax checker / type checker
			for the specification language Z.

solver_types		This directory contains an example solver type
			implementation and some sample applications.