Commit Graph

95 Commits

Author SHA1 Message Date
Zoltan Somogyi
ae7437c8f1 Recognize <<u and >>u as operators.
library/ops.m:
    Add these to the list of operators, at the same priority as << and >>.

library/mercury_term_lexer.m:
    <<u and >>u are the first operators that combine graphic characters with
    alphanumeric characters. This requires extending the lexer, because
    if the lexer, when given e.g. the string "<<u", returns "<<" and "u"
    as separate tokens, then the presence of <<u in the ops table
    would not matter.

    Implement this special case in all three different variants of the lexer.

doc/reference_manual.texi:
    Document the new operators, and their special-case nature.
2022-12-05 18:22:32 +11:00
Julien Fischer
3ed085c28d Fix spelling.
library/ops.m:
library/pprint.m:
library/pretty_printer.m:
library/term_io.m:
    As above.
2022-11-14 21:12:18 +11:00
Zoltan Somogyi
d481a42f59 Give each op class (infix, prefix etc) its own slot.
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.
2022-11-14 13:46:22 +11:00
Zoltan Somogyi
c6d857cb6b Cleanups of ops-related code.
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.
2022-11-12 12:53:07 +11:00
Zoltan Somogyi
4d15588c8b Address review comments.
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.
2022-11-12 01:36:32 +11:00
Zoltan Somogyi
de75b98b18 Make higher operator priorities bind tighter.
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.
2022-11-11 00:11:44 +11:00
Zoltan Somogyi
5bba0fbea1 Export operations on the Mercury op table.
library/ops.m:
    We used to export just the op_table typeclass and its mercury_op_table
    instance. This meant that even code that operated only on the Mercury
    op table and no other had to go through the typeclass interface, including
    the creation of a dummy mercury_op_table objects.

    Fix this by exporting the mercury_op_table implementations of the
    typeclass's methods in a form that does not require unnecessary arguments.
    Give these predicates and functions names derived from the names of the
    typeclass methods, just

    - with a "mercury_op_table_" prefix, and
    - with "lookup" replaced by "search" in the names of predicates
      that do searches that can fail.

    Factor the search of the op table out of the search predicates,
    and export separate predicates that do their work on already-lookup-up
    op_infos. This allows callers to avoid repeated work in some use cases.

NEWS:
    Announce the new predicates and functions.

library/pretty_printer.m:
    Exploit to the changes above, which were done with the use case in this
    module in mind.

library/stream.string_writer.m:
    Conform to the changes above.
2022-08-27 09:57:21 +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
06f81f1cf0 Add end_module declarations ...
.. to modules which did not yet have them.
2022-01-09 10:36:15 +11:00
Zoltan Somogyi
b64f0fbedc Add a "mercury_term_" prefix to lexer.m/parser.m.
library/mercury_term_lexer.m:
library/mercury_term_parser.m:
    As above.

NEWS:
    Announce the change.

browser/interactive_query.m:
compiler/analysis.file.m:
compiler/fact_table.m:
compiler/make.module_dep_file.m:
compiler/parse_module.m:
compiler/parse_tree_out_term.m:
compiler/recompilation.used_file.m:
library/MODULES_DOC:
library/char.m:
library/integer.m:
library/io.m:
library/library.m:
library/ops.m:
library/term.m:
library/term_io.m:
mdbcomp/trace_counts.m:
tests/hard_coded/impl_def_lex.m:
tests/hard_coded/impl_def_lex_string.m:
tests/hard_coded/lco_pack_args_3.m:
tests/hard_coded/lexer_bigint.m:
tests/hard_coded/lexer_ints.m:
tests/hard_coded/lexer_zero.m:
tests/hard_coded/parse_number_from_string.m:
tests/valid_seq/nested_module_bug.m:
    Conform to the change.
2021-12-31 02:38:07 +11:00
Zoltan Somogyi
0d7c8a7654 Specify pred or func for all pragmas.
*/*.m:
    As above.

configure.ac:
    Require the installed compiler to support this capability.
2021-06-16 15:23:58 +10:00
Zoltan Somogyi
6bd97a4031 Don't module qualify pred decls and clause heads. 2019-07-30 11:11:16 +02:00
Zoltan Somogyi
a12692a0de Replace /* */ comments with // in the library.
Keep the old style comments where they do not go to the end of the line,
or where it is important that the comment line not have a // on it.
2018-06-21 18:55:08 +02: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
Zoltan Somogyi
41c2fe79e8 Add a new language construct, the disable_warnings scope.
Its syntax is

    disable_warnings [warning_category1, ...] Goal

Its semantics is identical to Goal's semantics, with the only difference
being that the compiler will not generate warnings belonging to the listed
categories for code inside Goal.

At the moment, we support the disabling of two warning categories:
singleton variable warnings, and warnings about recursive calls that are not
*tail* recursive. However, the documentation of the latter is commented out
until we use the same code for generating such warnings regardless of what
backend generates code.

doc/reference_manual.texi:
    Document the new language extension.

NEWS:
    Mention the new language extension.

library/ops.m:
    Make "disable_warnings" (and its "disable_warning" variant) binary prefix
    operators, as required for the syntax of the new scope.

compiler/prog_item.m:
    Add disable_warnings_expr as a new kind of goal in the parse tree.

compiler/hlds_goal.m:
    Add disable_warnings as a new kind of scope goal in the HLDS.

compiler/prog_data.m:
    Add a type that represents the set of warnings that may be disabled.

    This type cannot be in prog_item.m, because it is needed by the HLDS,
    and we don't want the HLDS to depend on prog_item.m.

compiler/parse_goal.m:
    Parse the new kind of goal, transforming it from source code to parse tree.

compiler/goal_expr_to_goal.m:
    Transform the new kind of goal from parse tree to HLDS.

compiler/prog_out.m:
compiler/parse_tree_out_clause.m:
compiler/hlds_out_goal.m:
    Output the new kinds of parse tree and HLDS goals.

compiler/make_hlds_warn.m:
    Disable singleton variable warnings when the new scope asks for that.

compiler/mark_tail_calls.m:
    Disable warnings about non-tail-recursive recursive calls
    when the new scope asks for that.

    Improve a warning message.

compiler/ml_tailcall.m:
    Document why this sort-of-duplicate implementation of the
    warnings about non-tail-recursive recursive calls cannot respect
    the new scope. (I believe this sort-of-duplicate code should be deleted.)

    Improve the same warning message as in mark_tail_calls.m.

compiler/constraint.m:
compiler/det_analysis.m:
compiler/det_report.m:
compiler/erl_code_gen.m:
compiler/get_dependencies.m:
compiler/goal_util.m:
compiler/hlds_desc.m:
compiler/interval.m:
compiler/lambda.m:
compiler/modecheck_goal.m:
compiler/module_qual.collect_mq_info.m:
compiler/polymorphism.m:
compiler/prog_item_stats.m:
compiler/prog_util.m:
compiler/purity.m:
compiler/quantification.m:
compiler/saved_vars.m:
compiler/simplify_goal_scope.m:
compiler/simplify_proc.m:
compiler/stm_expand.m:
compiler/switch_detection.m:
compiler/try_expand.m:
compiler/typecheck.m:
compiler/unique_modes.m:
    Handle the new kind of scope.

    In a couple of places, fix comments.

tests/invalid/require_tailrec_1.{m,err_exp}:
    Wrap a disable_warnings scope around one of the non-tail-recursive
    recursive calls we used to get a warning about, and expect that
    we don't get this warning anymore. (We still do get this warning in grades
    that use ml_tailcall.m instead of mark_tail_calls.m to generate such
    warnings, as mentioned above.)

    Specify Mercury syntax highlighting for the source file.
    Expect the improved wording of a warning.

tests/invalid/require_tailrec_2.{m,err_exp}:
    Specify Mercury syntax highlighting for the source file.
    Expect the improved wording of a warning.

tests/warnings/singleton_test.m:
    Add a test of a singleton variable whose warning is disabled.
2017-01-11 02:00:32 +11:00
Zoltan Somogyi
95ff02b1bf Add options to check the ordering of module contents.
One option, --warn-non-contiguous-decls, generates warnings if the
mode declarations of a predicate or function aren't in a contiguous block
immediately following the pred or func declaration. Since this is a rare
kind of "style error", this option is enabled by default.

Two options, --warn-inconsistent-pred-order-clauses and
--warn-inconsistent-pred-order-foreign-procs, warn about inconsistencies
between (a) the order in which predicates (and functions) are declared,
and (b) the order in which they are defined. The two options differ in
their scope. The latter applies to all predicates and functions defined
in the module, while the former applies only to those whose definitions
include Mercury clauses.

Since an exported predicate or function may need nonexported auxiliary
predicates and/or functions, imposing a single order the declarations and
definitions of *all* the predicates and functions in a module is not a good
idea. Instead, both options divide the predicates and functions defined
in a module two groups, the exported and the nonexported, and expect
a consistent order only within each group.

The result is output that looks like this:

    time.m:021: Warning: the order of the declarations and definitions of the
    time.m:021:   exported predicates is inconsistent, as shown by this diff:
    time.m:021:
    time.m:021:   --- declaration order
    time.m:021:   +++ definition order
    time.m:021:   @@ -1,7 +1,7 @@
    time.m:021:    predicate `clock'/3
    time.m:021:   -predicate `time'/3
    time.m:021:    predicate `times'/4
    time.m:021:    function `clk_tck'/0
    time.m:021:   +predicate `time'/3
    time.m:021:    function `difftime'/2
    time.m:021:    predicate `localtime'/4
    time.m:021:    function `localtime'/1

compiler/options.m:
doc/user_guide.texi:
    Add the new options.

compiler/style_checks.m:
    A new module that generates the new warnings if warranted.

compiler/check_hlds.m:
compiler/notes/compiler_design.html:
    Include and document the new module.

compiler/mercury_compile_front_end.m:
    Invoke the new module if any of the three new options is set.

compiler/hlds_pred.m:
    Record the item number of every predicate, function, and mode declaration
    in the module being compiled. We need this for information for the
    new warnings.

compiler/hlds_module.m:
    Record the context of the module declaration. We use this context
    for warnings about inconsistent order, since there isn't a better one.

compiler/hlds_clauses.m:
    Add a mechanism to retrieve the item numbers of a set of clauses
    even if they are contiguous.

    Document some old data types.

compiler/error_util.m:
    Add a new phase for style checks.

compiler/accumulator.m:
compiler/add_class.m:
compiler/add_mutable_aux_preds.m:
compiler/add_pragma_tabling.m:
compiler/add_pred.m:
compiler/add_solver.m:
compiler/add_special_pred.m:
compiler/check_typeclass.m:
compiler/clause_to_proc.m:
compiler/from_ground_term_util.m:
compiler/lambda.m:
compiler/make_hlds.m:
compiler/make_hlds_passes.m:
compiler/mercury_compile.m:
compiler/par_loop_control.m:
compiler/polymorphism.m:
compiler/stm_expand.m:
compiler/table_gen.m:
compiler/unify_proc.m:
    Conform the changes to the HLDS above.

compiler/typecheck_errors.m:
    Fix style of error messages.

library/array2d.m:
library/assoc_list.m:
library/benchmarking.m:
library/bit_buffer.write.m:
library/bool.m:
library/builtin.m:
library/construct.m:
library/cord.m:
library/counter.m:
library/float.m:
library/injection.m:
library/lazy.m:
library/lexer.m:
library/ops.m:
library/private_builtin.m:
library/profiling_builtin.m:
library/prolog.m:
library/queue.m:
library/rational.m:
library/require.m:
library/stack.m:
library/std_util.m:
library/store.m:
library/thread.semaphore.m:
library/tree234.m:
library/univ.m:
library/version_store.m:
    Move declarations or definitions around to avoid some of the warnings
    that we can now generate. (There are many more left.)

    Make some minor style improvements in the process.

tests/warnings/inconsistent_pred_order.{m,exp}:
tests/warnings/non_contiguous_decls.{m,exp}:
    New test cases to test the new options. They are both copies of
    tests/benchmarks/queens.m, with intentionally-screwed-up style.

tests/warnings/Mmakefile:
    Enable the new test cases.

tests/warnings/Mercury.options:
    Specify the options being tested for the new test cases.

tests/benchmarks/queens.m:
    Bring the style of this module up to date (before copying it).

tests/invalid/mode_decl_in_wrong_section.err_exp:
    Expect the warnings we now generate.
2016-10-15 17:26:32 +11:00
Zoltan Somogyi
f2c714b1d1 Add missing ops to the reference manual.
doc/reference_manual.texi:
    Fix bitrot, as above.

library/ops.m:
    Put operators in alphabetical order in their group.
2015-10-07 16:47:41 +11:00
Zoltan Somogyi
0da23e02c5 Add syntax for saying what type an inst is for.
As agreed on the developers mailing dist, this syntax is

:- inst i(...) for tc/n
    --->    f1(...)
    ;       f2(...)
    ...
    ;       fn(...).

It also works on the equivalent syntax

:- inst i(...) for tc/n == bound(...).

The type constructor may be specified only for insts that are being
defined to be equivalent to bound insts, since only for these can we
check that the top level function symbols belong to the specified type
constructor.

There is no documentation of the new language extension yet, since it is
not yet really useful. That would come later, when we check that an inst
specified as for being for a specific type is used only on values
of that type. We would also need to resolve the two issues marked with
"XXX IFTC" in the diff.

compiler/prog_item.m:
    Add a field to the parse tree representation of inst definitions
    to record the absence or presence of the "for type" type constructor.

compiler/hlds_data.m:
    Modify the representation of inst definitions to allow recording
    the fact that an inst is declared to be for a specified type constructor,
    to allow recording the presence of an error in this regard (the inst
    is not for the type, or the inst is exported to places where the type
    is not visible). Differentiate between no type constructor being associated
    with the type because (a) it would not make sense, and (b) it would make
    sense, but no type constructor was specified. (After type-constructor-
    specific insts have been in the language long enough, we may want to
    generate a warning or even an error for the latter.)

library/ops.m:
    Add "for" as an operator, as discussed on the mailing list.

NEWS:
doc/reference_manual.texi:
    Announce and document the new operator.

compiler/prog_io_mode_defn.m:
    Parse the new bit of syntax.

    Give a predicate a more meaningful name.

compiler/parse_tree_out.m:
    Output the new piece of syntax in inst definitions if needed.

compiler/add_mode.m:
    When adding an inst defn in the parse tree to the HLDS, record the
    absence or presence of the "for type" type constructor, and if it is
    absent, whether it would have made sense for one to be present. Generate
    an error message if one is present when it doesn't make sense for it to be
    present.

compiler/equiv_type.m:
    Note that we should expand the type constructors in inst defns,
    and note a related issue that is probably a very old bug.

compiler/inst_check.m:
    For insts that are declared to be a specific type constructor, don't
    check whether there is SOME type constructor they are compatible with.
    Check whether they are compatible with their declared type, and if they
    aren't, generate an error, not a warning.

compiler/module_qual.m:
    Module qualify any type constructors in inst definitions.

compiler/inst_user.m:
compiler/intermod.m:
compiler/prog_io_util.m:
compiler/recompilation.check.m:
compiler/recompilation.usage.m:
compiler/recompilation.version.m:
compiler/write_module_interface_files.m:
    Conform to the changes above.

tests/dppd/grammar_impl.m:
    Protect a function symbol named "for" against being considered an operator.

tests/invalid/bad_inst_for_type.{m,err_exp}:
    A new test case, to see whether we get the expected set of error messages
    for incorrect use of the new language extension; no more, and no less.

tests/invalid/Mmakefile:
    Enable the new test case.
2015-10-04 18:06:33 +11:00
Zoltan Somogyi
9533fdb328 Convert (C->T;E) to (if C then T else E). 2015-09-06 23:29:44 +10: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
Zoltan Somogyi
3080515d3a Add require_switch_arms_{det,semidet,...} to the language.
The new construct looks like this:

    require_switch_arms_det [C] (
        (
            C = 'a',
            ... compute Out ...
        ;
            C = 'b',
            ... compute Out ...
        )
    )

If any of the goals computing Out are not det, the compiler will generate
an error message. The det at the end of the keyword can be replaced
by any of the other seven determinisms, though I don't think either
require_switch_arms_failure or require_switch_arms_erroneous will see much use.

This diff adds only the implementation. I will add the documentation
and the NEWS item after we all had a chance to install this diff and
try it out.

compiler/hlds_goal.m:
    Add a scope representing this kind of goal in the HLDS.

compiler/prog_item.m:
    Add a goal expression for this kind of goal in the parse tree.

compiler/prog_io_goal.m:
    Look for the new kind of goal expression in terms when creating
    the parse tree.

    Factor out some commonalities between the parsing of the new goal
    expression and existing types of goal expressions.

compiler/goal_expr_to_goal.m:
    Convert the new kind of goal expression to the new scope in the HLDS.

compiler/det_report.m:
    Implement the checks that the new goal type calls for.

    Factor out some commonalities between the implementation of the new goal
    type and existing goal types.

    Move the types and predicates dealing with comparisons of determinisms
    from here to prog_data.m, due to the sort-of-bugfix to modecheck_call.m.

compiler/prog_data.m:
    Move the types and predicates dealing with comparisons of determinisms
    from det_report.m to here. The old code for this was intended for only one
    requirement, and did not deal well with comparisons of two determinisms
    in which each determinism makes an assertion the other does not make.
    Create a way to represent such comparison results.

compiler/modecheck_call.m:
    When deciding which mode of a procedure to call, we prefer determinisms
    that make more assertions about solution counts. However, when comparing
    incomparable determinisms (such as semidet vs multi, each of which makes
    an assertion the other doesn't), the algorithm chose based solely
    on the ORDER of the modes. We now explicitly prefer modes that promise
    lower maximum solution counts, giving less importance to cannot_fail
    assertions.

compiler/*.m:
    Conform to the change to hlds_goal.m or prog_item.m.

library/ops.m:
    Add the new keywords as operators.

tests/hard_coded/require_scopes.{m,exp}:
    Extend this test case to test the new construct in the absence of errors.

tests/invalid/require_scopes.{m,exp}:
    Extend this test case to test the new construct in the presence of errors.
2014-11-14 12:46:46 +11:00
Julien Fischer
eaad77b7df Address some old XXXs in the library.
Branches: main

Address some old XXXs in the library.

library/term.m:
	Delete an ancient comment regarding the choice of type
	qualification operator; it's been ':' for quite some time
	now.

library/ops.m:
	Not being able to modify the table of Mercury operators
	is a good thing, not an XXX.

library/term_io.m:
	Delete an ancient comment regarding user-defined operators
	for the term parser being NYI.  We aren't likely to ever
	implement them in the way described in the comment since
	the op_table/1 type class provides an alternative way
	of dealing with the problem.

	Delete a comment in the interface that says we are
	in the interface.  For the source code this is obvious,
	it occurs directly below the interface declaration
	and for the library reference manual it is redundant clutter
	since everyting in the manual is an interface.
2012-01-03 14:09:02 +00:00
Zoltan Somogyi
e77bcdc4ba Add two new kinds of scopes to the language: one that requires the goal inside
Estimated hours taken: 12
Branches: main

Add two new kinds of scopes to the language: one that requires the goal inside
the scope to have a given determinism, and one that requires it
to be complete, i.e. to have arms for all the function symbols in the type of
the switched-on variable.

The first kind of scope adds the keywords

	require_det require_semidet
	require_multi require_nondet
	require_cc_multi require_cc_nondet
	require_erroneous require_failure

to the language. They are intended to be used like this:

	test_detism_scope(A, !IO) :-
	    (
		A > 10,
		require_det (
		    B = A * 2,
		    C = B mod 3
		),
		C = 1
	    ->
		X = C
	    ;
		X = A
	    ),
	    io.format("test_detism_scope(%d) = %d\n", [i(A), i(X)], !IO).

The second kind of scope adds the keyword require_complete_switch to
the language. They are intended to be used like this:

	do_test_switch_scope(A, X) :-
	    require_complete_switch [A] (
		(
		    A = f1,
		    fail
		;
		    A = f2,
		    ( X = 1
		    ; X = 2
		    )
		;
		    A = f3(B),
		    ( X = 3
		    ; X = B
		    ; X = B + 1
		    )
		)
	    ).

NEWS:
	Announce the new scopes.

doc/reference_manual.texi:
	Document the new scopes.

library/ops.m:
	Add the new keywords as operators.

compiler/hlds_goal.m:
	Add the new kinds of scopes to the HLDS.

compiler/prog_item.m:
	Add the new kinds of scopes to the parse tree type.

compiler/prog_io_goal.m:
	Recognize the new keywords. When we find a term with one of these
	keywords as the function symbol, generate the corresponding parse tree
	goal expression.

compiler/add_clause.m:
	Convert these goal expressions to HLDS.

compiler/simplify.m:
	Check the requirements expressed by the new scopes. If the requirement
	is met, delete the scope wrapper. If the requirement is not met,
	generate an error message and then delete the scope wrapper.

compiler/error_util.m:
	Add a new format_component, words_qoute, which is like quote, but
	yields words, not fixed, after quoting.

compiler/constraint.m:
compiler/det_analysis.m:
compiler/erl_code_gen.m:
compiler/goal_util.m:
compiler/hlds_desc.m:
compiler/hlds_out_goal.m:
compiler/interval.m:
compiler/lambda.m:
compiler/make_hlds_warn.m:
compiler/mercury_to_mercury.m:
compiler/mode_errors.m:
compiler/modecheck_goal.m:
compiler/module_imports.m:
compiler/module_qual.m:
compiler/polymorphism.m:
compiler/prog_util.m:
compiler/purity.m:
compiler/quantification.m:
compiler/saved_vars.m:
compiler/stm_expand.m:
compiler/try_expand.m:
compiler/typecheck.m:
	Conform to the changes to the parse tree and HLDS goal types.
	In one module, take advantage of the new format_component.

tests/hard_coded/require_scopes.{m,exp}:
	A new test case to test the handling of the new scopes when their
	requirements are met.

tests/hard_coded/Mmakefile:
	Add the new test.

tests/invalid/require_scopes.{m,err_exp}:
	A new test case to test the handling of the new scopes when their
	requirements are NOT met.

tests/invalid/Mmakefile:
	Add the new test.
2010-12-29 04:52:23 +00:00
Peter Wang
cc8923b7f7 Add support for `try' goals, syntactic sugar on top of the exception handling
Branches: main

Add support for `try' goals, syntactic sugar on top of the exception handling
predicates in the standard library.  The syntax is documented in the reference
manual.  Currently one of the proposed try parameters, io(!IO), is implemented.

Try goals are implemented by *two* source-to-source transformations, one at the
parse tree level, then a later one on the HLDS.  The reason for this is given
in try_expand.m.


library/ops.m:
	Add three new operators: try, catch, catch_any.

library/exception.m:
	Add forwarding predicates so that code generated by the try goal
	transformation doesn't need to import `univ'.

compiler/prog_item.m:
	Add representations of try goals to parse tree.

compiler/prog_io_goal.m:
	Parse try goals.

	Unrelated: fix spelling of "parameter".

compiler/add_clause.m:
	Perform the initial transformation on try goals.

compiler/hlds_goal.m:
	Add try goals to HLDS, as shorthand goals.

compiler/try_expand.m:
	New module to perform the latter transformation on try goals.

compiler/check_hlds.m:
	Import the new module.

compiler/mercury_compile.m:
	Call the try_expand pass near the end of the front-end pass.

compiler/module_imports.m:
	Implicitly import `exception' if a `try' goal is seen.

compiler/det_analysis.m:
	Conform to addition of try goals in HLDS.  Make it not wrap a commit
	scope around the intermediate try goal (as it might if there are no
	outputs) as it is inappropriate.

compiler/prog_util.m:
	Conform to parse tree changes.

compiler/assertion.m:
compiler/build_mode_constraints.m:
compiler/cse_detection.m:
compiler/delay_partial_inst.m:
compiler/dependency_graph.m:
compiler/det_report.m:
compiler/equiv_type_hlds.m:
compiler/format_call.m:
compiler/goal_form.m:
compiler/goal_path.m:
compiler/goal_util.m:
compiler/hlds_out.m:
compiler/intermod.m:
compiler/lambda.m:
compiler/make_hlds_warn.m:
compiler/mercury_to_mercury.m:
compiler/mode_util.m:
compiler/modes.m:
compiler/module_qual.m:
compiler/ordering_mode_constraints.m:
compiler/polymorphism.m:
compiler/post_typecheck.m:
compiler/prop_mode_constraints.m:
compiler/purity.m:
compiler/quantification.m:
compiler/simplify.m:
compiler/stm_expand.m:
compiler/stratify.m:
compiler/structure_reuse.lfu.m:
compiler/switch_detection.m:
compiler/type_constraints.m:
compiler/typecheck.m:
compiler/unique_modes.m:
compiler/unused_imports.m:
	Conform to changes in HLDS.

compiler/il_peephole.m:
compiler/ilasm.m:
compiler/ilds.m:
compiler/mlds_to_il.m:
	Rename some symbols to avoid the new keywords.

library/exception.m:
	Add two helper predicates for the try goal transformations.

doc/reference_manual.texi:
NEWS:
	Document and announce the new language feature.

compiler/notes/compiler_design.html:
	Note new compiler module.

tests/hard_coded/Mmakefile:
tests/hard_coded/try_syntax_1.exp:
tests/hard_coded/try_syntax_1.m:
tests/hard_coded/try_syntax_2.exp:
tests/hard_coded/try_syntax_2.m:
tests/hard_coded/try_syntax_3.exp:
tests/hard_coded/try_syntax_3.m:
tests/hard_coded/try_syntax_4.exp:
tests/hard_coded/try_syntax_4.m:
tests/hard_coded/try_syntax_5.exp:
tests/hard_coded/try_syntax_5.m:
tests/hard_coded/try_syntax_6.exp:
tests/hard_coded/try_syntax_6.m:
tests/hard_coded/try_syntax_7.exp:
tests/hard_coded/try_syntax_7.m:
tests/invalid/Mmakefile:
tests/invalid/try_bad_params.err_exp:
tests/invalid/try_bad_params.m:
tests/invalid/try_io_else.err_exp:
tests/invalid/try_io_else.m:
	Add test cases.

tests/debugger/declarative/catch.m:
	The module name is now a keyword so requires brackets.

tests/invalid/trace_goal_env.err_exp:
	Update test case for fixed spelling for "parameter".

vim/syntax/mercury.vim:
	Add try, catch, catch_any as keywords.
2009-03-10 05:00:34 +00:00
Julien Fischer
d44a9ac9c9 Remove support for implicit purity scopes from Mercury.
Estimated hours taken: 1
Branches: main

Remove support for implicit purity scopes from Mercury.

Unrelated change: disable a test case that no longer works
due to the recent change in the behaviour of string.to_int/2
and friends.

compiler/purity.m:
compiler/add_clause.m:
compiler/add_pred.m:
compiler/constraint.m:
compiler/dep_par_conj.m:
compiler/det_analysis.m:
compiler/erl_code_gen.m:
compiler/goal_util.m:
compiler/granularity.m:
compiler/hlds_desc.m:
compiler/hlds_goal.m:
compiler/hlds_out.m:
compiler/interval.m:
compiler/make_hlds_passes.m:
compiler/mercury_to_mercury.m:
compiler/modes.m:
compiler/module_imports.m:
compiler/module_qual.m:
compiler/prog_data.m:
compiler/prog_io_dcg.m:
compiler/prog_io_goal.m:
compiler/prog_item.m:
compiler/prog_util.m:
compiler/quantification.m:
compiler/saved_vasr.m:
compiler/simplify.m:
compiler/ssdebug.m:
compiler/stm_expand.m:
compiler/typecheck.m:
doc/reference_manual.texi:
library/ops.m:
	Remove implicit purity scopes from the language and implementation.

tests/hard_coded/Mmakefile:
tests/hard_coded/impure_foreign[23].{m,exp}:
tests/hard_coded/test_promise_impure_implicit.{m,exp}:
	Delete tests cases for implicit purity scopes.

tests/hard_coded/minint_bug.m:
	Disable this test case.  It no longer works after
	Ralph's recent change to strint.to_int/2 and friends.
	(Furthermore, it never excercised the behaviour it was
	meant to be checking for on 64-bit machines.)
2009-02-19 03:49:20 +00:00
Zoltan Somogyi
b000cb322e Provide compiler support for Software Transactional Memory through the new
Estimated hours taken: 80 by zs, and lots more by lmika
Branches: main

Provide compiler support for Software Transactional Memory through the new
atomic goal. This work was done by Leon Mika; I merely brought it up to date,
resolved conflicts, and cleaned up a few things. There are still several
aspects that are as yet incomplete.

library/ops.m:
	Add the operators needed for the syntax of atomic scopes.

library/stm_builtin.m:
	Add the builtin operations needed for the implementation of atomic
	goals.

compiler/hlds_goal.m:
	Add a new HLDS goal type, which represents an atomic goal and its
	possible fallbacks (in case an earlier goal throws an exception).

	Rename the predicate goal_is_atomic as goal_expr_has_subgoals,
	since now its old name would be misleading.

compiler/prog_data.m:
compiler/prog_item.m:
	Add a parse tree representation of the new kind of goal.

compiler/prog_io_goal.m:
	Parse the new kind of goal.

compiler/add_clause.m:
	Translate atomic goals from parse tree form to HLDS.

compiler/typecheck.m:
compiler/typecheck_errors.m:
	Do type checking of atomic goals.

compiler/modes.m:
	Do mode checking of atomic goals, and determine whether they are nested
	or not.

compiler/unique_modes.m:
	Do unique mode checking of atomic goals.

compiler/stm_expand.m:
	New module to expand atomic goals into sequences of simpler goals.

library/stm_builtin.m:
	Add the primitives needed by the transformation.

	Improve the existing debugging support.

mdbcomp/prim_data.m:
	Add utility functions to allow stm_expand.m to refer to modules in the
	library.

mdbcomp/program_representation.m:
	Expand the goal_path type to allow the representation of components of
	atomic goals.

compiler/notes/compiler_design.html:
	Document the new module.

compiler/transform_hlds.m:
	Include the new module in the compiler.

compiler/mercury_compile.m:
	Invoke the STM transformation.

compiler/hlds_module.m:
	Add an auxiliary counter used by the STM transformation.

compiler/hlds_pred.m:
	Add a new predicate origin: the STM transformation.

compiler/modules.m:
	Import the STM builtin module automatically if the module contains any
	atomic goals.

compiler/assertion.m:
compiler/bytecode_gen.m:
compiler/clause_to_proc.m:
compiler/code_gen.m:
compiler/code_info.m:
compiler/code_util.m:
compiler/constraint.m:
compiler/cse_detection.m:
compiler/deep_profiling.m:
compiler/code_util.m:
compiler/delay_construct.m:
compiler/delay_partial_inst.m:
compiler/dep_par_conj.m:
compiler/dependency_graph.m:
compiler/det_analysis.m:
compiler/det_report.m:
compiler/distance_granularity.m:
compiler/equiv_type_hlds.m:
compiler/erl_code_gen.m:
compiler/exception_analysis.m:
compiler/follow_code.m:
compiler/format_call.m:
compiler/goal_form.m:
compiler/goal_path.m:
compiler/goal_util.m:
compiler/granularity.m:
compiler/hlds_out.m:
compiler/implicit_parallelism.m:
compiler/inlining.m:
compiler/intermod.m:
compiler/lambda.m:
compiler/layout_out.m:
compiler/lco.m:
compiler/lookup_switch.m:
compiler/make_hlds_warn.m:
compiler/mark_static_terms.m:
compiler/mercury_to_mercury.m:
compiler/middle_rec.m:
compiler/ml_code_gen.m:
compiler/mode_constraint_robdd.m:
compiler/mode_constraints.m:
compiler/mode_errors.m:
compiler/mode_info.m:
compiler/mode_util.m:
compiler/ordering_mode_constraints.m:
compiler/pd_cost.m:
compiler/pd_util.m:
compiler/polymorphism.m:
compiler/post_typecheck.m:
compiler/prog_rep.m:
compiler/prog_type.m:
compiler/prop_mode_constraints.m:
compiler/rbmm.actual_region_arguments.m:
compiler/rbmm.add_rbmm_goal_info.m:
compiler/rbmm.condition_renaming.m:
compiler/rbmm.execution_path.m:
compiler/rbmm.points_to_analysis.m:
compiler/rbmm.region_transformation.m:
compiler/saved_vars.m:
compiler/simplify.m:
compiler/size_prog.m:
compiler/smm_common.m:
compiler/structure_reuse.direct.choose_reuse.m:
compiler/structure_reuse.direct.detect_garbage.m:
compiler/structure_reuse.indirect.m:
compiler/structure_reuse.lbu.m:
compiler/structure_reuse.lfu.m:
compiler/structure_reuse.versions.m:
compiler/structure_sharing.analysis.m:
compiler/switch_detection.m:
compiler/unused_imports.m:
compiler/granularity.m:
compiler/granularity.m:
	Conform to the changes above. Mostly this means handling the new
	kind of goal.

compiler/add_heap_ops.m:
compiler/add_trail_ops.m:
compiler/build_mode_constraints.m:
compiler/closure_analysis.m:
compiler/dead_proc_elim.m:
compiler/deforest.m:
compiler/follow_vars.m:
compiler/higher_order.m:
compiler/live_vars.m:
compiler/liveness.m:
compiler/loop_inv.m:
compiler/module_qual.m:
compiler/prog_util.m:
compiler/purity.m:
compiler/quantification.m:
compiler/store_alloc.m:
compiler/stratify.m:
compiler/tabling_analysis.m:
compiler/term_constr_build.m:
compiler/term_pass1.m:
compiler/term_traversal.m:
compiler/trailing_analysis.m:
	Conform to the changes above. Mostly this means handling the new
	kind of goal.

	Switch syntax from clauses to disj.

runtime/mercury_stm.[ch]:
	Implement the primitives needed by the STM transformation.

	Add more debugging support to the existing primitives.

library/term.m:
	Generalize get_term_context to work on terms of all kinds.
2008-02-27 07:23:57 +00:00
Peter Ross
e3f8bbf9aa Implement the TypeCtorInfo RTTI so that generic compare
Estimated hours taken: 16
Branches: main

Implement the TypeCtorInfo RTTI so that generic compare
and unify work via rtti_implementation.

However after discussion with zs, this current design of
RTTI has to be adapted to become more erlang specific, due
to the different data representation on the erlang backend.
The current code will serve as a template for this new design
though, which is why it is being checked in.

Add various erlang library implementations which are
needed to run useful programs when testing the erlang backend.

compiler/elds.m:
	Add a type_info_id.

compiler/elds_to_erlang.m:
	We now generate type_ctor_info's so call them.

compiler/erl_rtti.m:
	After discussions with zs, type_info and pseudo_type_infos
	should never occur on the erlang backend as they are needed
	for gc and the debugger so throw an exception for them.
	Add an implementation of creating a static type_info, but which
	isn't used in case we need it again later.
	Create type_ctor_info with all the fields except the
	TypeFunctors, the TypeLayout and the FunctorNumberMap

compiler/special_pred.m:
	Make sure we generate RTTI for the builtin types.

library/builtin.m:
library/char.m:
library/exception.m:
library/float.m:
library/int.m:
library/io.m:
library/lexer.m:
library/math.m:
library/mutvar.m:
library/ops.m:
library/par_builtin.m:
library/private_builtin.m:
library/rtti_implementation.m:
library/solutions.m:
library/store.m:
library/string.m:
library/table_builtin.m:
library/thread.semaphore.m:
library/time.m:
library/type_desc.m:
	Erlang implementations of std library functions.
2007-05-30 08:16:09 +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
9cd94b5c72 Various minor cleanups and syntax updates for the standard library.
Estimated hours taken: 1
Branches: main

Various minor cleanups and syntax updates for the standard library.
There are no changes to any algorithms.

library/injection.m:
library/set.m:
library/sparse_bitset.m:
	Use promise_equivalent_clauses where appropriate.

library/set_ordlist.m:
library/set_unordlist.m:
	Convert these module to 4-space indentation:
		Convert these module to 4-space indentation

library/*.m:
	Convert some if-then-elses into switches.

	Remove unnecessary module qualification - this is related
	mainly to the breakup of std_util and the fact that on
	the 0.13 branche we had two versions of the all-solutions
	predicates.

	Various other style cleanups.

vim/syntax/mercury.vim:
	Highlight promise_equivalent_clauses appropriately.
2006-10-23 00:33:04 +00:00
Zoltan Somogyi
89d49bcbb0 Change the representation of operators to allow a single lookup to
Estimated hours taken: 4
Branches: main

library/ops.m:
	Change the representation of operators to allow a single lookup to
	gather all available information about an operator.

NEWS:
	Mention the change to ops.m.

library/io.m:
	When writing out terms, use the new functionality of ops.m to look up
	the function symbol in the operator table just one (previously we did
	it up to five times).

	Rename some predicates to eliminate some ambiguities.
2006-09-25 02:44:45 +00:00
Zoltan Somogyi
91501d2453 This diff is the first step in implementing trace events.
Estimated hours taken: 12
Branches: main

This diff is the first step in implementing trace events. It introduces the
representation of trace event goals into both the parse tree and HLDS
representations, and updates most compiler passes to handle them.
Changes to the code generator and to the runtime system, user-level
documentation and test cases will come later.

library/ops.m:
	Add "event" as an operator.

mdbcomp/program_representation.m:
	Extend the representation of goals to include events.

browser/declarative_execution.m:
	Allow the reconstruction from bytecode of event goals.

browser/declarative_tree.m:
	Extend the algorithm for following terms to their sources to allow
	it to traverse events (which never generate any values).

compiler/prog_item.m:
compiler/hlds_goal.m:
	Extend the parse tree and the HLDS representations to include event
	goals.

compiler/prog_io_goal.m:
	Convert the term representation of events to the parse tree
	representation.

compiler/add_clause.m:
	Convert the parse tree representation of events to the HLDS
	representation.

compiler/prog_event.m:
	Add this new module to contain the compiler's database of event types.

compiler/notes/compiler_design.html:
	Mention the new module.

compiler/parse_tree.m:
	Include the new module.

compiler/prog_rep.m:
	Generate the extended bytecode for event goals.

compiler/mercury_to_mercury.m:
	Output event goals.

compiler/typecheck.m:
	Typecheck event goals. The types of the arguments of each event type
	is given by the database in prog_event.m.

compiler/typecheck_errors.m:
	Add a predicate for reporting unknown events.

compiler/modecheck_call.m:
	Add a predicate to modecheck event goals. The modes of the arguments
	are also given by the database in prog_event.m.

compiler/modes.m:
	Call the new predicate in modecheck_call.m for event goals.

	Some predicates in this module took a boolean flag, tested many times
	at runtime, to control whether an exact match was required or not.
	However, the choice was fixed at all call sites except one. I have
	split each predicate into two, one for each value of the boolean flag,
	both for clarity of code and for slightly improved speed.

compiler/ml_call_gen.m:
	Ignore event goals, since the MLDS backend doesn't support debugging.

compiler/call_gen.m:
	Document the fact that event goals *should* be handled here.

compiler/build_mode_constraints.m:
compiler/deep_profiling.m:
compiler/exception_analysis.m:
compiler/goal_util.m:
compiler/hlds_out.m:
compiler/hlds_pred.m:
compiler/intermod.m:
compiler/mercury_to_mercury.m:
compiler/mlds_to_c.m:
compiler/mode_constraints.m:
compiler/modecheck_unify.m:
compiler/module_qual.m:
compiler/prog_util.m:
compiler/purity.m:
compiler/simplify.m:
compiler/superhomogeneous.m:
compiler/tabling_analysis.m:
compiler/term_traversal.m:
compiler/trailing_analysis.m:
compiler/typecheck.m:
compiler/typecheck_errors.m:
compiler/unique_modes.m:
	Handle the new goal type. In most cases the new code should be
	functional, but in a few cases (e.g. constraint based mode analysis
	and deep profiling) it just aborts the compiler.
2006-09-05 06:21:37 +00:00
Zoltan Somogyi
9d23d8e2e7 Implement the trace goal construct we discussed, for now for the LLDS backends
Estimated hours taken: 70
Branches: main

Implement the trace goal construct we discussed, for now for the LLDS backends
only.

Since the syntax of trace goals is non-trivial, useful feedback on syntax
errors inside trace goal attributes is essential. With the previous setup, this
wasn't possible, since the code that turned terms into parse tree goals turned
*all* terms into goals; it couldn't recognize any errors, sweeping them under
the rug as calls. This diff changes that. Now, if this code recognizes a
keyword that indicates a particular construct, it insists on the rest of the
code following the syntax required for that construct, and returns error
messages if it doesn't.

We handle the trace goal attributes that specify state variables to be threaded
through the trace goal (either the I/O state or a mutable variable) in
add_clause.m, at the point at which we transform the list of items to the HLDS.
We handle the compile-time condition on trace goals in the invocation of
simplify at the end of semantics analysis, by eliminating the goal if the
compile-time condition isn't met. We handle run-time conditions on trace goals
partially in the same invocation of simplify: we transform trace goals with
runtime conditions into an if-then-else with the trace goal as the then part
and `true' as the else part, the condition being a foreign_proc that is handled
specially by the code generator, that special handling being to replace
the actual code of the foreign_proc (which is a dummy) with the evaluation of
the runtime condition.

Since these changes require significant changes to some of our key data
structures, I took the liberty of doing some renaming of function symbols
at the same time to avoid using ambiguities with respect to language keywords.

library/ops.m:
	Add "trace" as an operator.

compiler/prog_data.m:
	Define data types to represent the various attributes of trace goals.

	Rename some function symbols to avoid ambiguities.

compiler/prog_item.m:
	Extend the parse tree representation of goals with a trace goal.

compiler/mercury_to_mercury.m:
	Output the new kind of goal and its components.

compiler/hlds_goal.m:
	Extend the HLDS representation of scopes with a scope_reason
	representing trace goals.

	Add a mechanism (an extra argument in foreign_procs) to allow
	the representation of goals that evaluate runtime trace conditions.

	Since this requires modifying all code that traverses the HLDS,
	do some renames that were long overdue: rename not as negation,
	rename call as plain_call, and rename foreign_proc as
	call_foreign_proc. These renames all avoid using language keywords
	as function symbols.

	Change the way we record goals' purities. Instead of optional features
	to indicate impure or semipure, which is error-prone, use a plain
	field in the goal_info, accessed in the usual way.

	Add a way to represent that a goal contains a trace goal, and should
	therefore be treated as if it were impure when considering whether to
	optimize it away.

	Reformat some comments describing function symbols.

compiler/hlds_out.m:
	Output the new construct in the HLDS.

compiler/prog_io_util.m:
	Generalize the maybe[123] types to allow the representation of more
	than one error message. Add functions to extract the error messages.
	Add a maybe4 type. Rename the function symbols of these types to
	avoid massive ambiguity.

	Change the order of some predicates to bring related predicates
	next to each other.

compiler/prog_io.m:
compiler/prog_io_dcg.m:
compiler/prog_io_goal.m:
compiler/prog_io_pragma.m:
	Rework these modules almost completely to find and accumulate syntax
	errors as terms are being parsed. In some cases, this allowed us to
	replace "XXX this is a hack" markers with meaningful error-reporting
	code.

	In prog_io_goal.m, add code for parsing trace goals.

	In a bunch of places, update obsolete coding practices, such as using
	nested chains of closures instead of simple sequential code, and
	using A0 and A to refer to values of different types (terms and goals
	respectively). Use more meaningful variable names.

	Break up some too-large predicates.

compiler/superhomogeneous.m:
	Find and accumulate syntax errors as terms are being parsed.

compiler/add_clause.m:
	Add code to transform trace goals from the parse tree to the HLDS.
	This is where the IO state and mutable variable attributes of trace
	goals are handled.

	Eliminate the practice of using the naming scheme Body0 and Body
	to refer to values of different types (prog_item.goal and hlds_goal
	respectively).

	Use error_util for some error messages.

library/private_builtin.m:
	Add the predicates referred to by the transformation in add_clause.m.

compiler/goal_util.m:
	Rename a predicate to avoid ambiguity.

compiler/typecheck.m:
	Do not print error messages about missing clauses if some errors have
	been detected previously.

compiler/purity.m:
	Instead of just computing purity, compute (and record) also whether
	a goal contains a trace goal. However, treat trace goals as pure.

compiler/mode_info.m:
	Add trace goals as a reason for locking variables.

	Rename some function symbols to avoid ambiguity.

compiler/modes.m:
	When analyzing trace goal scopes, lock the scope's nonlocal variables
	to prevent them from being further instantiated.

compiler/det_analysis.m:
	Insist on the code in trace goal scopes being det or cc_multi.

compiler/det_report.m:
	Generate the error message if the code in a trace goal scope isn't det
	or cc_multi.

compiler/simplify.m:
	At the end of the front end, eliminate trace goal scopes if their
	compile-time condition is false. Transform trace goals with runtime
	conditions as described at the top.

	Treat goals that contain trace goals as if they were impure when
	considering whether to optimize them away.

compiler/mercury_compile.m:
	Tell simplify when it is being invoked at the end of the front end.

	Rename a predicate to avoid ambiguity.

compiler/trace_params.m:
	Provide the predicates simplify.m need to be able to evaluate the trace
	goal conditions regarding trace levels.

compiler/trace.m:
compiler/trace_gen.m:
	Rename the trace module as trace_gen, since "trace" is now an operator.

	Rename some predicates exported by the module, now that it is no longer
	possible to preface calls with "trace." as a module qualifier.

compiler/notes/compiler_design.html:
	Document this name change.

compiler/options.m:
	Rename the trace option as trace_level internally, since "trace"
	is now an operator. The user-visible name remains the same.

	Add the new --trace-flag option.

	Delete an obsolete option.

compiler/handle_options.m:
	Rename the function symbols of the grade_component type,
	since "trace" is now an operator.

compiler/llds.m:
	Extend the LLDS with a mechanism to refer to C global variables.
	For now, these are used to refer to C globals that will be created
	by mkinit to represent the initial values of the environment variables
	referred to by trace goals.

compiler/commit_gen.m:
	Check that no trace goal with a runtime condition survives to code
	generation; they should have been transformed by simplify.m.

compiler/code_gen.m:
	Tell commit_gen.m what kind of scope it is generating code for.

compiler/pragma_c_gen.m:
	Generate code for runtime conditions when handling the foreign_procs
	created by simplify.m.

compiler/code_info.m:
	Allow pragma_c_gen.m to record what environment variables it has
	generated references to.

compiler/proc_gen.m:
	Record the set of environment variables a procedure refers to
	in the LLDS procedure header, for efficient access by llds_out.m.

compiler/llds_out.m:
	Handle the new LLDS construct, and tell mkinit which environment
	variables need C globals created for them.

compiler/pd_util.m:
	Rename some predicates to avoid ambiguity.

compiler/*.m:
	Conform to the changes above, mainly the renames of function symbols
	and predicates, the changed signatures of some predicates, and the new
	handling of purity.

util/mkinit.c:
	Generate the definitions and the initializations of any C globals
	representing the initial status (set or not set) of environment
	variables needed by trace goals.

library/assoc_list.m:
	Add some predicates that are useful in prog_io*.m.

library/term_io.m:
	Minor cleanup.

tests/hard_coded/trace_goal_{1,2}.{m,exp}:
	New test cases to test the new construct, identical except for whether
	the trace goal is enabled at compile time.

tests/hard_coded/trace_goal_env_{1,2}.{m,exp}:
	New test cases to test the new construct, identical except for whether
	the trace goal is enabled at run time.

tests/hard_coded/Mercury.options:
tests/hard_coded/Mmakefile:
	Enable the new test cases.

tests/invalid/*.err_exp:
	Update the expected output for the new versions of the error messages
	now being generated.
2006-07-27 05:03:54 +00:00
Julien Fischer
e0f5ac47db Make it easier for vi to jump past the initial comments
Estimated hours taken: 0.1
Branches: main

library/*.m:
	Make it easier for vi to jump past the initial comments
	at the head of a module.
2006-04-19 05:18:00 +00:00
Julien Fischer
5e92224eec Improve the library reference manual by formatting the beginning of
Estimated hours taken: 0.2
Branches: main, release

library/*.m:
	Improve the library reference manual by formatting the beginning of
	library modules consistently.

library/integer.m:
	Fix some bad indentation.
2006-04-13 06:08:05 +00:00
Zoltan Somogyi
19159de6b7 Add a new goal form, as discussed on our mailing lists:
Estimated hours taken: 12
Branches: main

Add a new goal form, as discussed on our mailing lists:

	promise_equivalent_solution_sets [Vars] (
		arbitrary [Vars1] Goal1,
		arbitrary [Vars2] Goal2,
		...
	)

NEWS:
	Mention the new goal form.

doc/reference_manual.texi:
	Document the new goal form.

library/ops.m:
	Add "promise_equivalent_solution_sets" and "arbitrary" as new
	operators.

compiler/prog_item.m:
	Add a parse_tree representation of new constructs.

	Change the representation of goal forms in the parse tree to avoid
	using punctuation marks as function symbols, to avoid function symbols
	that need quoting, and to avoid ambiguity with hlds_goal_expr.

	Delete the obsolete if_then (no else) goal form.

compiler/hlds_goal.m:
	Provide a HLDS representation of the new constructs.

compiler/det_analysis.m:
	Implement the rules for processing the new constructs.

compiler/det_report.m:
	Implement the messages for the errors that can occur with the
	new constructs.

	Add quotes around `promise_equivalent_solutions' in an existing error
	message, for consistency.

compiler/prog_io_goal.m:
	Parse the new goal constructs.

compiler/add_clause.m:
compiler/hlds_out.m:
compiler/make_hlds_passes.m:
compiler/make_hlds_warn.m:
compiler/mercury_to_mercury.m:
compiler/module_qual.m:
compiler/pd_util.m:
compiler/prog_io.m:
compiler/prog_io_dcg.m:
compiler/prog_io_goal.m:
compiler/prog_util.m:
compiler/saved_vars.m:
compiler/simplify.m:
	Conform to the changes to prog_item.m and hlds_goal.m.

tests/hard_coded/one_member.{m,exp}:
	New test case to test the proper functioning of the new construct.

tests/invalid/one_member.{m,err_exp}:
	New test case to test the kinds of errors that can occur when using
	the new construct.

tests/hard_coded/Mmakefile:
tests/invalid/Mmakefile:
	Enable the new test cases.

tests/invalid/promise_equivalent_solutions_test.err_exp:
	Expect quotes around an old construct name, after the change to
	det_report.m.
2006-03-21 22:25:39 +00:00
Zoltan Somogyi
b293bd999d Replace __ with . as the module qualifier everywhere.
Estimated hours taken: 1
Branches: main

library/*.m:
	Replace __ with . as the module qualifier everywhere.

tests/hard_coded/test_injection.exp:
	Replace __ with . as the module qualifier in expected exceptions.
2006-03-07 22:23:58 +00:00
Mark Brown
8ae09930f8 Fix a bug reported by Doug Auclair.
Estimated hours taken: 5
Branches: main

Fix a bug reported by Doug Auclair.

library/ops.m:
	Change the Mercury arg priority to 999.  It was previously set to
	1201, which allowed arguments and list elements to be parsed the
	way we intended.  However, this had the unintended side effect that
	valid terms were written out using incorrect syntax.

library/parser.m:
	Place the workaround here, where arguments and list elements are
	read.

	Note that this is still technically buggy, because we effectively
	allow syntax which should be illegal according to the operator
	precedence table.  But the proper fix for this involves moving to
	a BNF style parser, so that is left for later work.

tests/hard_coded/Mmakefile:
	Run the term_io_test case twice, checking it against the expected
	output each time.  The first time it is run with the supplied input
	file.  The second time it is run with the expected output as input --
	this ensures that terms are read in the same way that they are
	written out.

tests/hard_coded/term_io_test.m:
	Read input from stdin rather than a fixed file.

tests/hard_coded/term_io_test.inp:
	Add additional input terms.

tests/hard_coded/term_io_test.exp:
tests/invalid/*.err_exp:
	Update the expected output for this and other test cases.
2006-03-07 01:03:46 +00:00
Julien Fischer
9d8ca0ad37 Remove residual parts of the Aditi backend that weren't deleted the other day.
Estimated hours taken: 1.5
Branches: main

Remove residual parts of the Aditi backend that weren't deleted the other day.

configure.in:
Mmake.common.in:
	Remove support for enabling the Aditi backend.

runtime/mercury_aditi.h:
	Remove this file.

runtime/Mmakefile:
runtime/mercury.h:
runtime/mercury_imp.h:
runtime/mercury_ho_call.[ch]:
runtime/mercury_wrapper.[ch]:
	Delete support for Aditi in the runtime.

scripts/Mmake.rules:
scripts/Mmake.vars.in:
scripts/c2init.in:
scripts/parse_ml_options.sh-subr.in:
	Remove mmake support for building .rlo files, etc.

util/mkinit.c:
	Remove Aditi specific code.

compiler/bytecode_data.m:
compiler/closure_analysis.m:
compiler/code_model.m:
compiler/compile_target_code.m:
compiler/det_analysis.m:
compiler/handle_options.m:
compiler/hlds_goal.m:
compiler/hlds_module.m:
compiler/make.dependencies.m:
compiler/make.m:
compiler/make.module_target.m:
compiler/make.program_target.m:
compiler/make.util.m:
compiler/make_hlds_error.m:
compiler/make_hlds_passes.m:
compiler/mercury_to_mercury.m:
compiler/mlds_to_gcc.m:
compiler/modecheck_call.m:
compiler/modules.m:
compiler/opt_debug.m:
compiler/options.m:
compiler/prog_data.m:
compiler/prog_foreign.m:
compiler/prog_mode.m:
compiler/prog_type.m:
compiler/rtti.m:
compiler/rtti_out.m:
compiler/rtti_to_mlds.m:
compiler/term_errors.m:
compiler/unify_proc.m:
mdbcomp/prim_data.m:
	Remove residual support for Aditi.

library/ops.m:
	Remove the 'aditi_bottom_up' and 'aditi_top_down' operators from the
	ops table.

doc/reference_manual.texi:
doc/user_guide.texi:
	Delete the sections on the Aditi interface.

extras/aditi/*:
	Delete this.
2006-02-24 07:11:21 +00:00
Julien Fischer
ec146456f2 Delete pre-0.12 deprecated predicates.
Estimated hours taken: 0.5
Branches: main

library/io.m:
	Delete pre-0.12 deprecated predicates.

library/list.m:
library/set_bbbtree.m:
library/ops.m:
	Fix some doubled-up words in the documentation.

library/term_to_xml.m:
	Delete the XXX comments about tabling some of the predicates
	in this module.  This is not going ahead.

	'..' is now an infix operator so it doesn't need to be quoted.

	Fix a doubled-up word.
2005-11-15 04:59:23 +00:00
Zoltan Somogyi
57b8f436eb Convert to four-space indentation most of the library modules that
Estimated hours taken: 4
Branches: main

library/*.m:
	Convert to four-space indentation most of the library modules that
	weren't already indented that way. Use predmode syntax where possible.
	In some modules, shorten long lines by deleting module name prefixes.
	Fix departures from our coding standards.

	In some modules, simplify code, mostly using field names and/or state
	variables.

	There are no changes in algorithms, except for neg_list in integer.m.
2005-10-17 11:35:22 +00:00
Julien Fischer
2755655989 Support impure initialise and finalise predicates in user code.
Estimated hours taken: 4
Branches: main

Support impure initialise and finalise predicates in user code.  In order to
support this the arity of the initialise or finalise predicate can no longer be
optionally omitted from the declaration.  Supporting impure arity zero
initialise/finalise declarations removes the restriction that every module that
has an initialise/finalise declaration must import the io module.

Allow initialize/finalize to be used as synonyms for initialise/finalise.

Improve the documentation of initialise/finalise declarations.
In particular:

	- mention the above changes.
	- mention that they may be cc_multi.
	- specify the order in which they invoked with respect to
	  standard library initialisation/finalisation.
	- mention that these declarations are not currently available
	  on non-C backends.

compiler/make_hlds_passes.m:
	Support impure user initialise/finalise predicates.

compiler/mercury_to_mercury.m:
	Write out the arities of the predicates specified in
	initialise and finalise declarations.

compiler/prog_data.m:
	Add an arity field to the initialise and finalise items.

compiler/prog_io.m:
	Don't allow the arity to be omitted in initialise and finalise
	declarations.

compiler/module_qual.m:
compiler/modules.m:
compiler/recompilation.check.m:
compiler/recompilation.version.m:
	Conform to the changes in the initialise and finalise items.

library/ops.m:
	Add the alternate spellings of initialise and finalise to the ops
	table.

doc/reference_manual.texi:
	Update the ops table.

	Mention that initialise and finalise predicates may be cc_multi.

	Document impure initialisation and finalisation predicates.

	Add some disclaimers: mutable, initialise and finalise declarations
	are not implemented for the non-C backends.

tests/hard_coded/Mmakefile:
tests/hard_coded/impure_init_and_final.m:
tests/hard_coded/impure_init_and_final.exp:
	Test impure initialise and finalise declarations.

tests/hard_coded/finalise_decl.m:
tests/hard_coded/intialise_decl.m:
	Conform to the above changes.  Also test the versions of the
	declarations that use the -ize ending.

tests/hard_coded/sub-modules/finalise_parent.m:
tests/hard_coded/sub-modules/initialise_child.m:
tests/hard_coded/sub-modules/initialise_parent.m:
	Conform to the above changes.

tests/invalid/bad_finalise.m:
tests/invalid/bad_finalise.err_exp:
tests/invalid/bad_initialise.m:
tests/invalid/bad_initialise.err_exp:
	Extend these tests to check for missing or bad arities
	in intialise or finalise declarations.

vim/syntax/mercury.vim:
	Highlight recently added syntax appropriately.
2005-10-04 07:20:24 +00:00
Julien Fischer
f57fe1b7df Add language and compiler support for finalise declarations.
Estimated hours taken: 8
Branches: main

Add language and compiler support for finalise declarations.

NEWS:
	Mention finalise declarations.

compiler/prog_data.m:
	Add a new item type for finalise declarations.

	Add a new kind of item origin - items can now be introduced as part of
	the source-to-source transformation that implements finalise
	declarations.

compiler/prog_io.m:
	Parse finalise declarations.

compiler/modules.m:
	Don't write out finalise declarations in private interfaces.

compiler/hlds_module.m:
	Add a slot to the HLDS that stores the names of the predicates in
	finalise declarations.

	Add access predicates for the above.

compiler/add_pragma.m:
compiler/make_hlds_passes.m:
	Fix in incorrect comment: we add initialise declarations on third, not
	second, pass.

	Restore the code that use the enhanced switch detection capability.

	Implement the source-to-source transformation that implements finalise
	declarations.  This is almost identical to that for intitialise
	declarations.

compiler/llds.m:
compiler/llds_out.m:
compiler/transform_llds.m:
	Add a slot to the LLDS to hold the name of the predicates specified in
	the finalise declarations.

	Emit the necessary code to call these predicates after main has finished.

compiler/mlds.m:
compiler/ml_code_gen.m:
compiler/ml_elim_nested.m:
compiler/ml_optimize.m:
compiler/ml_tailcall.m:
compiler/mlds_to_c.m:
compiler/mlds_to_gcc.m:
compiler/mlds_to_il.m:
compiler/mlds_to_ilasm.m:
compiler/mlds_to_java.m:
compiler/mlds_to_managed.m:
	As above, but for the MLDS.

compiler/mercury_compile.m:
	Conform to changes in the MLDS.
	XXX This module probably shouldn't manipulating the MLDS directly.

compiler/module_qual.m:
compiler/mercury_to_mercury.m:
compiler/recompilation.check.m:
compiler/recompilation.version.m:
	Conform to the above changes.

library/ops.m:
	Add `finalise' as an operator.

runtime/mercury_wrapper.c:
	Call any user specified finalise predicates from
	mercury_runtime_terminate.

doc/reference_manual.texi:
	Document finalise declarations.

tests/hard_coded/Mmakefile:
tests/hard_coded/finalise_decl.m:
tests/hard_coded/finalise_decl.exp:
	Tests finalise declarations.

tests/hard_coded/sub-modules/Mmakefile:
tests/hard_coded/sub-modules/finalise_child.m:
tests/hard_coded/sub-modules/finalise_parent.m:
tests/hard_coded/sub-modules/finalise_parent.{exp,exp2}:
	Test finalise declarations and sub-modules.  There are two expected
	outputs because the order of execution between a parent module and its
	children of any finalisers is arbitrary.

tests/invalid/Mmakefile:
tests/invalid/bad_finalise_decl.m:
tests/invalid/bad_finalise_decl.err_exp:
	Test error messages associated with finalise declarations.
2005-09-29 06:33:17 +00:00
Julien Fischer
168cb85743 Make ':' into an infix type qualification operator, equivalent to with_type.
Estimated hours taken: 2
Branches: main

Make ':' into an infix type qualification operator, equivalent to `with_type`.

compiler/prog_io.m:
	Handle type qualifications in pred and func declarations that use ':'.

compiler/superhomogeneous.m:
	Handle type qualifications using ':' in clauses.

library/ops.m:
	Change the precedence of ':' so that it is identical to `with_type`.

doc/reference_manual.texi:
	Update the list of operators.
	Update the section on explicit type qualification expressions.

tests/hard-coded/type_qual.m:
	Use the new syntax in this test case.
	(There are lots of other test cases that exercise the old syntax.)

NEWS:
	Mention that ':' is now the type qualification operator.
2005-09-26 06:52:08 +00:00
Julien Fischer
7d334f9be7 Remove support for old-style lambda expressions.
Estimated hours taken: 1
Branches: main

Remove support for old-style lambda expressions.  These have been deprecated
for a long time now.  Mercury 0.12 issues a warning if you try to use this
syntax.

compiler/prog_io_goal.m:
compiler/superhomogeneous.m
	Do not support parsing old style lambda expressions.

	Do not issue a warning about old-style lambdas being deprecated.

library/ops.m:
	Delete 'lambda' from the operator table.

doc/reference_manual.texi:
	Delete references to the old style lambda expressions.

tests/hard_coded/typeclasses/constrained_lambda.m:
tests/hard_coded/typeclasses/extra_typeinfo.m:
	Update the syntax for lambda expressions.
2005-09-13 03:25:43 +00:00
Ralph Becket
88b75863dc Add support for initialisation predicates to be called before main/2 is
Estimated hours taken: 16
Branches: main

Add support for initialisation predicates to be called before main/2 is
invoked.  The new directive is `:- initialise initpredname.'

NEWS:
	Mention the new functionality.

compiler/export.m:
	`:- pragma export' also adds a C function declaration in the
	generated C wrapper code to avoid C compiler warnings about
	missing declarations.

compiler/hlds_module.m:
	Added a new user_init_preds field to the module_info to
	record the preds named in `initialise' directives.
	Added predicates to access and update the new field.
	The exported names are generated automatically.

compiler/llds.m:
	Added a new field cfile_num_user_inits to c_file structure.

compiler/llds_out.m:
	Add code to include the `REQUIRED_INIT initpredexportname' lines
	in the comment section of the generated C that is recognised
	by mkinit.

compiler/make_hlds_passes.m:
	Handle the new `initialise' directives.

compiler/mercury_compile.m:
	Make sure the list of user defined init pred export names is passed to
	the C code construction preds.

compiler/mercury_to_mercury.m:
	Handle the output of `initialise' directives.

compiler/module_qual.m:
compiler/modules.m:
compiler/recompilation.check.m:
compiler/recompilation.version.m:
	Handle the new `initialise' item.

compiler/prog_data.m:
	Add a new `initialise(sym_name)' item.

compiler/prog_io.m:
	Add code to parse `initialise' directives.

compiler/prog_mode.m:
	Add di_mode pred and func.

compiler/transform_llds.m:
	Handle the extra field in c_file.

doc/reference_manual.texi:
	Update the operator table in the reference manual.
	Document the new `initialise' directive.

library/list.m:
	Added index[01]_of_first_occurrence preds and
	det_index[01]_of_first_occurrence funcs.  I've often
	had a need for these and they are used in looking up
	initprednames in the new module_info field.

library/ops.m:
	Add `initialise' as a prefix operator.

runtime/mercury_wrapper.c:
runtime/mercury_wrapper.h:
	Add a new exported variable, MR_address_of_init_modules_required.
	Call the function pointed to by this variable at the right point
	during module initialisation.

test/hard_coded/Mmakefile:
test/hard_coded/initialise_decl.exp:
test/hard_coded/initialise_decl.m:
test/invalid/Mmakefile:
test/invalid/bad_initialise_decl.err_exp:
test/invalid/bad_initialise_decl.m:
	Added test cases.

util/mkinit.c:
	Now always checks C files for extra inits (previously you had to
	explicitly supply the -x flag).
2005-08-29 03:22:32 +00:00
Ralph Becket
6761328d46 Extend the promise_<purity> scopes.
Estimated hours taken: 3
Branches: main

Extend the promise_<purity> scopes.

compiler/hlds_goal.m:
	Added some comment lines to the scope_reaon documentation to make it
	clear to which constructor each comment pertains.

compiler/prog_io_goal.m:
compiler/purity.m:
library/ops.m:
	Added promise_impure as a scope.

	Added promise_{pure,semipure,impure}_implicit scopes.  These are
	identical to promise_{pure,semipure,impure} respectively, except that
	purity annotations on goals within the scope are optional.

	Purity warnings are no longer issued if the scope body has a lesser
	impurity than the promised purity.  To make this work, I've added a
	field `implicit_purity' to the purity_info constructor, which is either
	`make_implicit_promises' or `dont_make_implicit_promises'.  If the
	latter, then purity errors and warnings are suppressed.

doc/reference_manual.texi:
	Document the new syntax.

tests/hard_coded/Mmakefile:
tests/hard_coded/impure_foreign2.m:
tests/hard_coded/impure_foreign2.exp:
tests/hard_coded/impure_foreign3.m:
tests/hard_coded/impure_foreign3.exp:
tests/hard_coded/test_promise_impure_implicit.m:
tests/hard_coded/test_promise_impure_implicit.exp:
	Added test cases.
2005-04-26 07:38:03 +00:00
Zoltan Somogyi
8b8b3b7d3f Replace the some() HLDS goal with a more general scope() goal, which can be
Estimated hours taken: 12
Branches: main

Replace the some() HLDS goal with a more general scope() goal, which can be
used not just for existential quantification but also for other purposes.

The main such purposes are new goal types that allow the programmer
to annotate arbitrary goals, and not just whole procedure bodies, with the
equivalents of promise_pure/promise_semipure and promise_only_solution:

	promise_pure ( <impure/semipure goal> )
	promise_semipure ( <impure goal> )

	promise_equivalent_solutions [OutVar1, OutVar2] (
		<cc_multi/cc_nondet goal that computed OutVar1 & OutVar2>
	)

Both are intended to be helpful in writing constraint solvers, as well as in
other situations.

doc/reference_manual.texi:
	Document the new constructs.

library/ops.m:
	Add the keywords of the new constructs to the list of operators.
	Since they work similarly to the "some" operator, they have the same
	precedence.

compiler/hlds_goal.m:
	Replace the some(Vars, SubGoal) HLDS construct, with its optional
	keep_this_commit attribute, with the new scope(Reason, SubGoal)
	construct. The Reason argument may say that this scope is an
	existential quantification, but it can also say that it represents
	a purity promise, the introduction of a single-solution context
	with promise_equivalent_solutions, or a decision by a compiler pass.

	It can also say that the scope represents a set of goals that all arise
	from the unraveling of a unification between a variable and a ground
	term. This was intended to speed up mode checking by significantly
	reducing the number of delays and wakeups, but the cost of the scopes
	themselves turned out to be bigger than the gain in modechecking speed.

	Update the goal_path_step type to refer to scope goals instead of just
	existential quantification.

compiler/prog_data.m:
	Add new function symbols to the type we use to represent goals in items
	to stand for the new Mercury constructs.

compiler/prog_io_goal.m:
	Add code to read in the new language constructs.

compiler/prog_io_util.m:
	Add a utility predicate for use by the new code in prog_io_goal.m.

compiler/make_hlds.m:
	Convert the item representation of the new constructs to the HLDS
	representation.

	Document how the from_ground_term scope reason would work, but do not
	enable the code.

compiler/purity.m:
	When checking the purity of goals, respect the new promise_pure and
	promise_semipure scopes. Generate warnings if such scopes are
	redundant.

compiler/det_analysis.m:
	Make the insides of promise_equivalent_solutions goals single solution
	contexts.

compiler/det_report.m:
	Provide mechanisms for reporting inappropriate usage of
	promise_equivalent_solutions goals.

compiler/instmap.m:
	Add a utility predicate for use by one of the modules above.

compiler/deep_profiling.m:
	Use one of the new scope reasons to prevent simplify from optimizing
	away commits of goals that have been made impure, instead of the old
	keep_this_commit goal feature.

compiler/modes.m:
	Handle from_ground_term scopes when present; for now, they won't be
	present, since make_hlds isn't creating them.

compiler/options.m:
	Add two new compiler options, for use by implementors only, to allow
	finer control over the amount of output one gets with --debug-modes.
	(I used them when debugging the performance of the from_ground_term
	scope reason.) The options are --debug-modes-minimal and
	--debug-modes-verbose.

compiler/handle_options.m:
	Make the options that are meaningful only in the presence of
	--debug-modes imply --debug-modes, since this allows more convenient
	(shorter) invocations.

compiler/mode_debug.m:
	Respect the new options when deciding how much data to print
	when debugging of the mode checking process is enabled.

compiler/switch_detect.m:
	Rename a predicate to make it differ from another predicate by more
	than just its arity.

compiler/passes_aux.m:
	Bring this module up to date with our current style guidelines,
	by using state variable syntax where appropriate.

compiler/*.m:
	Minor changes to conform to the change in the HLDS and/or parse tree
	goal type.

mdbcomp/program_representation.m:
	Rename the some goal to the scope goal, and the same for path steps,
	to keep them in sync with the HLDS.

browser/declarative_tree.m:
	Conform to the change in goal representations.

tests/hard_coded/promise_equivalent_solutions_test.{m,exp}:
	A new test case to test the handling of the
	promise_equivalent_solutions construct.

tests/hard_coded/Mmakefile:
	Enable the new test.

tests/hard_coded/purity/promise_pure_test.{m,exp}:
	A new test case to test the handling of the promise_pure and
	promise_semipure constructs.

tests/hard_coded/purity/Mmakefile:
	Enable the new test.

tests/invalid/promise_equivalent_solutions.{m,err_exp}:
	A new test case to test the error messages for improper use of the
	promise_pure and promise_semipure constructs.

tests/invalid/Mmakefile:
	Enable the new test.
2005-03-24 05:34:41 +00:00
Ralph Becket
d0bd460b8f Minor reformatting; added some renamed preds and funcs to improve
Estimated hours taken: 3
Branches: main, version-0_12-branch

library/array.m:
library/array2d.m:
library/assoc_list.m:
library/bag.m:
library/benchmarking.m:
library/bimap.m:
library/bintree_set.m:
library/bitmap.m:
library/bool.m:
library/builtin.m:
library/cord.m:
library/float.m:
library/graph.m:
library/group.m:
library/hash_table.m:
library/int.m:
library/lexer.m:
library/list.m:
library/map.m:
library/math.m:
library/multi_map.m:
library/ops.m:
library/parser.m:
library/rbtree.m:
library/set.m:
library/stack.m:
library/store.m:
library/string.m:
library/time.m:
	Minor reformatting; added some renamed preds and funcs to improve
	consistency of naming in the library; removed some preds and types that
	have been marked obsolete since 0.11.
2005-02-02 04:28:50 +00:00
Julien Fischer
1de1dbb394 Fix more typos in library documentation.
Estimated hours taken: 0.5
Branches: main

Fix more typos in library documentation.

library/builtin.m:
	s/wheiter/whether.

library/char.m:
	s/consise/concise/

library/getopt.m:
library/getopt_io.m:
	s/keept/keep/

library/int.m:
	s/expontiation/exponentiation/

library/ops.m:
	s/precendence/precedence/

library/robdd.m:
	s/efficent/efficient/

library/set_bbbtree.m:
	s/noticable/noticeable/

library/term_to_xml.m:
	s/funtor/functor/
	s/attrinutes/attributes/
	s/fuctor/functor/

library/version_array.m:
	s/incurr/incur/
2005-01-27 03:59:27 +00:00
Ralph Becket
868a0c7d04 Add `..' as an infix operator.
Estimated hours taken: 0.1
Branches: main

library/ops.m:
	Add `..' as an infix operator.

doc/reference_manual.texi:
	Updated to include new operator.
2004-12-16 03:23:12 +00:00