Files
mercury/tests/submodules/mutable_parent.m
Zoltan Somogyi eb6617c175 Rename X's aux modules as X_helper_N in submodules.
tests/submodules/*.m:
    Rename modules as mentioned above.

    Indent nested submodules to make them stand out.

    Group foreign_procs by what predicate they implement, not by
    their implementation language.

tests/submodules/*.m:
tests/submodules/*.err_exp:
tests/submodules/Mmakefile:
tests/submodules/Mercury.options:
    Update all references to the moved modules.
2023-06-19 22:16:36 +02:00

42 lines
1.2 KiB
Mathematica

%---------------------------------------------------------------------------%
% vim: ts=4 sw=4 et ft=mercury
%---------------------------------------------------------------------------%
%
:- module mutable_parent.
:- interface.
:- import_module io.
:- include_module mutable_parent_helper_1.
:- pred main(io::di, io::uo) is det.
:- implementation.
:- import_module int.
:- import_module list.
:- import_module string.
:- import_module mutable_parent.mutable_parent_helper_1.
:- import_module mutable_parent.mutable_parent_helper_1.mutable_parent_helper_2.
:- mutable(parent_global, int, 100, ground,
[untrailed, attach_to_io_state]).
main(!IO) :-
mutable_parent.run_parent(!IO),
mutable_parent.mutable_parent_helper_1.run_child(!IO),
mutable_parent.mutable_parent_helper_1.mutable_parent_helper_2.run_grandchild(!IO),
io.write_string("Back in parent ...\n", !IO),
get_parent_global(ParentGlobal, !IO),
io.format(" parent_global = %d\n", [i(ParentGlobal)], !IO).
:- pred run_parent(io::di, io::uo) is det.
run_parent(!IO) :-
io.write_string("In parent ...\n", !IO),
get_parent_global(X, !IO),
io.format(" parent_global = %d\n", [i(X)], !IO),
set_parent_global(X + 1, !IO).