§1. Package types.

    inter_symbol *plain_ptype = NULL;
    inter_symbol *code_ptype = NULL;
    inter_symbol *module_ptype = NULL;
    inter_symbol *function_ptype = NULL;
    inter_symbol *verb_ptype = NULL;
    inter_symbol *mverb_ptype = NULL;
    inter_symbol *to_phrase_ptype = NULL;
    inter_symbol *rule_ptype = NULL;
    inter_symbol *request_ptype = NULL;
    inter_symbol *closure_ptype = NULL;
    inter_symbol *response_ptype = NULL;
    inter_symbol *adjective_ptype = NULL;
    inter_symbol *adjective_meaning_ptype = NULL;
    inter_symbol *instance_ptype = NULL;
    inter_symbol *property_ptype = NULL;
    inter_symbol *variable_ptype = NULL;
    inter_symbol *kind_ptype = NULL;
    inter_symbol *action_ptype = NULL;
    inter_symbol *activity_ptype = NULL;
    inter_symbol *rulebook_ptype = NULL;
    inter_symbol *table_ptype = NULL;
    inter_symbol *table_column_ptype = NULL;
    inter_symbol *relation_ptype = NULL;
    inter_symbol *test_ptype = NULL;
    inter_symbol *outcome_ptype = NULL;
    inter_symbol *data_ptype = NULL;
    inter_symbol *external_file_ptype = NULL;
    inter_symbol *label_storage_ptype = NULL;

§2.

    void Packaging::emit_types(void) {
        plain_ptype = Emit::new_symbol(Inter::get_global_symbols(Emit::repository()), I"_plain");
        Emit::guard(Inter::PackageType::new_packagetype(Emit::IRS(), plain_ptype, Emit::baseline(Emit::IRS()), NULL));
        code_ptype = Emit::new_symbol(Inter::get_global_symbols(Emit::repository()), I"_code");
        Emit::guard(Inter::PackageType::new_packagetype(Emit::IRS(), code_ptype, Emit::baseline(Emit::IRS()), NULL));
        module_ptype = Emit::new_symbol(Inter::get_global_symbols(Emit::repository()), I"_module");
        Emit::guard(Inter::PackageType::new_packagetype(Emit::IRS(), module_ptype, Emit::baseline(Emit::IRS()), NULL));
        function_ptype = Emit::new_symbol(Inter::get_global_symbols(Emit::repository()), I"_function");
        Emit::guard(Inter::PackageType::new_packagetype(Emit::IRS(), function_ptype, Emit::baseline(Emit::IRS()), NULL));
        verb_ptype = Emit::new_symbol(Inter::get_global_symbols(Emit::repository()), I"_verb");
        Emit::guard(Inter::PackageType::new_packagetype(Emit::IRS(), verb_ptype, Emit::baseline(Emit::IRS()), NULL));
        mverb_ptype = Emit::new_symbol(Inter::get_global_symbols(Emit::repository()), I"_mverb");
        Emit::guard(Inter::PackageType::new_packagetype(Emit::IRS(), mverb_ptype, Emit::baseline(Emit::IRS()), NULL));
        to_phrase_ptype = Emit::new_symbol(Inter::get_global_symbols(Emit::repository()), I"_phrase");
        Emit::guard(Inter::PackageType::new_packagetype(Emit::IRS(), to_phrase_ptype, Emit::baseline(Emit::IRS()), NULL));
        rule_ptype = Emit::new_symbol(Inter::get_global_symbols(Emit::repository()), I"_rule");
        Emit::guard(Inter::PackageType::new_packagetype(Emit::IRS(), rule_ptype, Emit::baseline(Emit::IRS()), NULL));
        request_ptype = Emit::new_symbol(Inter::get_global_symbols(Emit::repository()), I"_request");
        Emit::guard(Inter::PackageType::new_packagetype(Emit::IRS(), request_ptype, Emit::baseline(Emit::IRS()), NULL));
        closure_ptype = Emit::new_symbol(Inter::get_global_symbols(Emit::repository()), I"_closure");
        Emit::guard(Inter::PackageType::new_packagetype(Emit::IRS(), closure_ptype, Emit::baseline(Emit::IRS()), NULL));
        response_ptype = Emit::new_symbol(Inter::get_global_symbols(Emit::repository()), I"_response");
        Emit::guard(Inter::PackageType::new_packagetype(Emit::IRS(), response_ptype, Emit::baseline(Emit::IRS()), NULL));
        adjective_ptype = Emit::new_symbol(Inter::get_global_symbols(Emit::repository()), I"_adjective");
        Emit::guard(Inter::PackageType::new_packagetype(Emit::IRS(), adjective_ptype, Emit::baseline(Emit::IRS()), NULL));
        adjective_meaning_ptype = Emit::new_symbol(Inter::get_global_symbols(Emit::repository()), I"_adjective_meaning");
        Emit::guard(Inter::PackageType::new_packagetype(Emit::IRS(), adjective_meaning_ptype, Emit::baseline(Emit::IRS()), NULL));
        instance_ptype = Emit::new_symbol(Inter::get_global_symbols(Emit::repository()), I"_instance");
        Emit::guard(Inter::PackageType::new_packagetype(Emit::IRS(), instance_ptype, Emit::baseline(Emit::IRS()), NULL));
        property_ptype = Emit::new_symbol(Inter::get_global_symbols(Emit::repository()), I"_property");
        Emit::guard(Inter::PackageType::new_packagetype(Emit::IRS(), property_ptype, Emit::baseline(Emit::IRS()), NULL));
        variable_ptype = Emit::new_symbol(Inter::get_global_symbols(Emit::repository()), I"_variable");
        Emit::guard(Inter::PackageType::new_packagetype(Emit::IRS(), variable_ptype, Emit::baseline(Emit::IRS()), NULL));
        kind_ptype = Emit::new_symbol(Inter::get_global_symbols(Emit::repository()), I"_kind");
        Emit::guard(Inter::PackageType::new_packagetype(Emit::IRS(), kind_ptype, Emit::baseline(Emit::IRS()), NULL));
        action_ptype = Emit::new_symbol(Inter::get_global_symbols(Emit::repository()), I"_action");
        Emit::guard(Inter::PackageType::new_packagetype(Emit::IRS(), action_ptype, Emit::baseline(Emit::IRS()), NULL));
        activity_ptype = Emit::new_symbol(Inter::get_global_symbols(Emit::repository()), I"_activity");
        Emit::guard(Inter::PackageType::new_packagetype(Emit::IRS(), activity_ptype, Emit::baseline(Emit::IRS()), NULL));
        rulebook_ptype = Emit::new_symbol(Inter::get_global_symbols(Emit::repository()), I"_rulebook");
        Emit::guard(Inter::PackageType::new_packagetype(Emit::IRS(), rulebook_ptype, Emit::baseline(Emit::IRS()), NULL));
        table_ptype = Emit::new_symbol(Inter::get_global_symbols(Emit::repository()), I"_table");
        Emit::guard(Inter::PackageType::new_packagetype(Emit::IRS(), table_ptype, Emit::baseline(Emit::IRS()), NULL));
        table_column_ptype = Emit::new_symbol(Inter::get_global_symbols(Emit::repository()), I"_table_column");
        Emit::guard(Inter::PackageType::new_packagetype(Emit::IRS(), table_column_ptype, Emit::baseline(Emit::IRS()), NULL));
        relation_ptype = Emit::new_symbol(Inter::get_global_symbols(Emit::repository()), I"_relation");
        Emit::guard(Inter::PackageType::new_packagetype(Emit::IRS(), relation_ptype, Emit::baseline(Emit::IRS()), NULL));
        test_ptype = Emit::new_symbol(Inter::get_global_symbols(Emit::repository()), I"_test");
        Emit::guard(Inter::PackageType::new_packagetype(Emit::IRS(), test_ptype, Emit::baseline(Emit::IRS()), NULL));
        outcome_ptype = Emit::new_symbol(Inter::get_global_symbols(Emit::repository()), I"_outcome");
        Emit::guard(Inter::PackageType::new_packagetype(Emit::IRS(), outcome_ptype, Emit::baseline(Emit::IRS()), NULL));
        data_ptype = Emit::new_symbol(Inter::get_global_symbols(Emit::repository()), I"_data");
        Emit::guard(Inter::PackageType::new_packagetype(Emit::IRS(), data_ptype, Emit::baseline(Emit::IRS()), NULL));
        external_file_ptype = Emit::new_symbol(Inter::get_global_symbols(Emit::repository()), I"_external_file");
        Emit::guard(Inter::PackageType::new_packagetype(Emit::IRS(), external_file_ptype, Emit::baseline(Emit::IRS()), NULL));
        label_storage_ptype = Emit::new_symbol(Inter::get_global_symbols(Emit::repository()), I"_label_storage");
        Emit::guard(Inter::PackageType::new_packagetype(Emit::IRS(), label_storage_ptype, Emit::baseline(Emit::IRS()), NULL));
    }

The function Packaging::emit_types is used in 27/ei (§3).

§3.

    enum VERB_PR_COUNTER from 0
    enum MVERB_PR_COUNTER
    enum FUNCTION_PR_COUNTER
    enum FORM_PR_COUNTER
    enum BLOCK_PR_COUNTER
    enum TO_PHRASE_PR_COUNTER
    enum RULE_PR_COUNTER
    enum REQUEST_PR_COUNTER
    enum CLOSURE_PR_COUNTER
    enum RESPONSE_PR_COUNTER
    enum ADJECTIVE_PR_COUNTER
    enum ADJECTIVE_MEANING_PR_COUNTER
    enum TASK_PR_COUNTER
    enum BLOCK_CONSTANT_PR_COUNTER
    enum LITERAL_PR_COUNTER
    enum PROPOSITION_PR_COUNTER
    enum INSTANCE_PR_COUNTER
    enum INLINE_PR_COUNTER
    enum PROPERTY_PR_COUNTER
    enum VARIABLE_PR_COUNTER
    enum KIND_PR_COUNTER
    enum ACTION_PR_COUNTER
    enum ACTIVITY_PR_COUNTER
    enum RULEBOOK_PR_COUNTER
    enum TABLE_PR_COUNTER
    enum TABLE_COLUMN_PR_COUNTER
    enum RELATION_PR_COUNTER
    enum SUBSTITUTION_PR_COUNTER
    enum SUBSTITUTIONF_PR_COUNTER
    enum MISC_PR_COUNTER
    enum DATA_PR_COUNTER
    enum OUTCOME_PR_COUNTER
    enum TEST_PR_COUNTER
    enum EXTERNAL_FILE_PR_COUNTER
    enum LABEL_STORAGE_PR_COUNTER
    enum MAX_PR_COUNTER
    typedef struct package_request {
        struct inter_name *eventual_name;
        struct inter_symbol *eventual_type;
        struct inter_package *actual_package;
        struct package_request *parent_request;
        struct inter_reading_state write_position;
        int counters[MAX_PR_COUNTER];
        MEMORY_MANAGEMENT
    } package_request;

The structure package_request is accessed in 26/iti, 27/ei and here.

§4.

    package_request *Packaging::request(inter_name *name, package_request *parent, inter_symbol *pt) {
        package_request *R = CREATE(package_request);
        R->eventual_name = name;
        if (parent) name->eventual_owner = parent;
        R->eventual_type = pt;
        R->actual_package = NULL;
        R->parent_request = parent;
        R->write_position = Inter::Bookmarks::new_IRS(Emit::repository());
        for (int i=0; i<MAX_PR_COUNTER; i++) R->counters[i] = 0;
        return R;
    }

    void Packaging::log(package_request *R) {
        if (R == NULL) LOG("<null-package>");
        else {
            int c = 0;
            while (R) {
                if (c++ > 0) LOG("\\");
                if (R->actual_package) LOG("%S(%d)", R->actual_package->package_name->symbol_name, R->allocation_id);
                else LOG("--(%d)", R->allocation_id);
                R = R->parent_request;
            }
        }
    }

The function Packaging::request is used in §7, §7.1, §8, 5/ins (§14), 5/nv (§16), 6/bp (§31), 15/pr (§27), 15/ma (§11.3), 17/rs (§5), 19/tc (§9), 19/tb (§9), 21/rl (§5), 21/rl2 (§10), 21/fao (§10), 21/ac (§6), 22/pav (§7), 22/tp (§5, §7), 26/jl (§3), 26/ts (§9.1), 27/ei (§3), 27/cm (§2).

The function Packaging::log is used in 1/cm (§5, §6.6).

§5.

    package_request *current_enclosure = NULL;

    typedef struct packaging_state {
        inter_reading_state *saved_IRS;
        package_request *saved_enclosure;
    } packaging_state;

    packaging_state Packaging::stateless(void) {
        packaging_state PS;
        PS.saved_IRS = NULL;
        PS.saved_enclosure = NULL;
        return PS;
    }

    package_request *Packaging::home_of(inter_name *N) {
        return N->eventual_owner;
    }

    packaging_state Packaging::enter_home_of(inter_name *N) {
        return Packaging::enter(N->eventual_owner);
    }

    packaging_state Packaging::enter_current_enclosure(void) {
        return Packaging::enter(current_enclosure);
    }

    package_request *Packaging::current_enclosure(void) {
        return current_enclosure;
    }

The function Packaging::stateless is used in 15/epv (§2).

The function Packaging::home_of is used in 12/cdp (§5), 27/hl (§1), 27/hr (§4).

The function Packaging::enter_home_of is used in 6/bp (§42), 6/rlt (§14, §15.1, §20, §20.3), 6/nv (§18), 12/cdp (§2.1.1), 13/kak (§5), 13/rsfk (§16.2, §26), 15/pr (§27), 15/epv (§1.1.2), 17/tl (§14.1, §14.2), 17/ts (§11), 17/rs (§7.3), 18/lc (§12.1), 19/rsft (§1.1.1.1, §1.1.1.1.1, §1.2, §1.3), 21/rl2 (§14, §20), 21/fao (§10), 21/ac (§6, §8, §14), 22/cs (§8), 22/pav (§8.1), 22/tp2 (§4), 24/ch (§6, §8), 26/vm (§8), 26/uo (§21), 26/lt (§4.1), 26/jl (§6), 26/rt (§1), 26/iti (§10), 26/pl (§12), 26/ts (§10), 27/ei (§4), 27/hr (§5).

The function Packaging::enter_current_enclosure is used in 13/rsfk (§4), 17/tl (§16), 17/ts (§8.1), 18/lc (§11).

The function Packaging::current_enclosure is used in 12/dtd (§4), 13/rsfk (§19), 17/tl (§7, §10.2.1, §14.2), 17/ts (§8, §8.1), 18/lc (§5, §11), 26/iti (§9).

The structure packaging_state is private to this section.

§6.

    define MAX_PACKAGING_ENTRY_DEPTH 32
    int packaging_entry_sp = 0;
    inter_reading_state packaging_entry_stack[MAX_PACKAGING_ENTRY_DEPTH];

    packaging_state Packaging::enter(package_request *R) {
        LOGIF(PACKAGING, "Entering $X\n", R);

        inter_reading_state *IRS = Emit::IRS();
        Packaging::incarnate(R);
        Emit::move_write_position(&(R->write_position));
        if (packaging_entry_sp >= MAX_PACKAGING_ENTRY_DEPTH) internal_error("packaging entry too deep");
        packaging_entry_stack[packaging_entry_sp] = Emit::bookmark_bubble();
        Emit::move_write_position(&packaging_entry_stack[packaging_entry_sp]);
        packaging_entry_sp++;
        packaging_state PS;
        PS.saved_IRS = IRS;
        PS.saved_enclosure = current_enclosure;
        for (package_request *S = R; S; S = S->parent_request)
            if ((S->eventual_type == function_ptype) ||
                (S->eventual_type == instance_ptype) ||
                (S->eventual_type == property_ptype) ||
                (S->eventual_type == variable_ptype) ||
                (S->eventual_type == action_ptype) ||
                (S->eventual_type == kind_ptype) ||
                (S->eventual_type == relation_ptype) ||
                (S->eventual_type == table_ptype) ||
                (S->eventual_type == table_column_ptype) ||
                (S->eventual_type == data_ptype) ||
                (S->eventual_type == outcome_ptype) ||
                (S->eventual_type == external_file_ptype) ||
                (S->eventual_type == adjective_ptype) ||
                (S->eventual_type == test_ptype) ||
                (S->eventual_type == closure_ptype) ||
                (S->parent_request == NULL)) {
                current_enclosure = S;
                break;
            }
        LOGIF(PACKAGING, "[%d] Current enclosure is $X\n", packaging_entry_sp, current_enclosure);
        return PS;
    }

    void Packaging::exit(packaging_state PS) {
        current_enclosure = PS.saved_enclosure;
        packaging_entry_sp--;
        LOGIF(PACKAGING, "[%d] Back to $X\n", packaging_entry_sp, current_enclosure);
        Emit::move_write_position(PS.saved_IRS);
    }

    inter_package *Packaging::incarnate(package_request *R) {
        if (R == NULL) internal_error("can't incarnate null request");
        if (R->actual_package == NULL) {
            LOGIF(PACKAGING, "Request to make incarnate $X\n", R);
            if (R->parent_request) Packaging::incarnate(R->parent_request);

            inter_reading_state *save_IRS = NULL;
            if (R->parent_request)
                save_IRS = Emit::move_write_position(&(R->parent_request->write_position));
            inter_reading_state snapshot = Emit::bookmark_bubble();
            inter_reading_state *save_save_IRS = Emit::move_write_position(&snapshot);
            Emit::package(R->eventual_name, R->eventual_type, &(R->actual_package));
            R->write_position = Emit::bookmark_bubble();
            Emit::move_write_position(save_save_IRS);
            if (R->parent_request)
                Emit::move_write_position(save_IRS);
            LOGIF(PACKAGING, "Made incarnate $X bookmark $5\n", R, &(R->write_position));
        }
        return R->actual_package;
    }

    inter_symbols_table *Packaging::scope(inter_repository *I, inter_name *N) {
        if (N == NULL) internal_error("can't determine scope of null name");
        if (N->eventual_owner == NULL) return Inter::get_global_symbols(Emit::repository());
        return Inter::Packages::scope(Packaging::incarnate(N->eventual_owner));
    }

The function Packaging::enter is used in §5, 4/am (§34.2), 5/ins (§34), 5/nv (§16), 13/rsfk (§16.1, §26), 15/epv (§2), 16/ic (§10), 17/rs (§6.1, §7.1), 21/rl (§9), 21/rl2 (§20), 22/ph (§12), 27/ei (§3, §4), 27/hl (§1).

The function Packaging::exit is used in 5/ins (§34), 5/nv (§16), 6/bp (§42), 6/rlt (§14, §15.1, §20, §20.3), 6/nv (§18), 12/cdp (§2.1.1), 13/kak (§5), 13/rsfk (§4, §16.1, §16.2, §26), 15/pr (§27), 15/epv (§1.1.2, §2), 16/ic (§10), 17/tl (§14.1, §14.2, §16), 17/ts (§8.1, §11), 17/rs (§6.1, §7.1, §7.3), 18/lc (§11, §12.1), 19/rsft (§1.1.1.1, §1.1.1.1.1, §1.2, §1.3), 21/rl (§9), 21/rl2 (§14, §20), 21/fao (§10), 21/ac (§6, §8, §14), 22/cs (§8), 22/ph (§12), 22/pav (§8.1), 22/tp2 (§4), 24/ch (§6, §8), 26/vm (§8), 26/uo (§21), 26/lt (§4.1), 26/jl (§6), 26/rt (§4), 26/iti (§10), 26/pl (§12), 26/ts (§10), 27/ei (§3, §4), 27/hl (§1), 27/hr (§5).

The function Packaging::incarnate is used in 21/rl (§9), 27/ei (§3).

The function Packaging::scope is used in 27/in (§2).

§7.

    package_request *main_pr = NULL;
    package_request *Packaging::request_main(void) {
        if (main_pr == NULL)
            main_pr = Packaging::request(InterNames::one_off(I"main", NULL), NULL, plain_ptype);
        return main_pr;
    }

    package_request *resources_pr = NULL;
    package_request *Packaging::request_resources(void) {
        if (resources_pr == NULL)
            resources_pr = Packaging::request(
                InterNames::one_off(I"resources", Packaging::request_main()),
                Packaging::request_main(), plain_ptype);
        return resources_pr;
    }

    package_request *generic_pr = NULL;
    package_request *Packaging::request_generic(void) {
        if (generic_pr == NULL)
            generic_pr = Packaging::request(
                InterNames::one_off(I"generic", Packaging::request_resources()),
                Packaging::request_resources(), module_ptype);
        return generic_pr;
    }

    package_request *template_pr = NULL;
    package_request *Packaging::request_template(void) {
        if (template_pr == NULL)
            template_pr = Packaging::request(
                InterNames::one_off(I"template", Packaging::request_resources()),
                Packaging::request_resources(), module_ptype);
        return template_pr;
    }

    package_request *synoptic_pr = NULL;
    package_request *Packaging::request_synoptic(void) {
        if (synoptic_pr == NULL)
            synoptic_pr = Packaging::request(
                InterNames::one_off(I"synoptic", Packaging::request_resources()),
                Packaging::request_resources(), module_ptype);
        return synoptic_pr;
    }

    typedef struct subpackage_requests {
        struct package_request *subs[MAX_SUBMODULE];
    } subpackage_requests;

    void Packaging::initialise_subpackages(subpackage_requests *SR) {
        for (int i=0; i<MAX_SUBMODULE; i++) SR->subs[i] = NULL;
    }

    int generic_subpackages_initialised = FALSE;
    subpackage_requests generic_subpackages;
    int synoptic_subpackages_initialised = FALSE;
    subpackage_requests synoptic_subpackages;

    package_request *Packaging::request_resource(compilation_module *C, int ix) {
        subpackage_requests *SR = NULL;
        package_request *parent = NULL;
        if (C) {
            SR = Modules::subpackages(C);
            parent = C->resources;
        } else {
            if (generic_subpackages_initialised == FALSE) {
                generic_subpackages_initialised = TRUE;
                Packaging::initialise_subpackages(&generic_subpackages);
            }
            SR = &generic_subpackages;
            parent = Packaging::request_generic();
        }
        <Handle the resource request 7.1>;
    }

    package_request *Packaging::local_resource(int ix) {
        return Packaging::request_resource(Modules::find(current_sentence), ix);
    }

    package_request *Packaging::generic_resource(int ix) {
        if (generic_subpackages_initialised == FALSE) {
            generic_subpackages_initialised = TRUE;
            Packaging::initialise_subpackages(&generic_subpackages);
        }
        subpackage_requests *SR = &generic_subpackages;
        package_request *parent = Packaging::request_generic();
        <Handle the resource request 7.1>;
    }

    package_request *Packaging::synoptic_resource(int ix) {
        if (synoptic_subpackages_initialised == FALSE) {
            synoptic_subpackages_initialised = TRUE;
            Packaging::initialise_subpackages(&synoptic_subpackages);
        }
        subpackage_requests *SR = &synoptic_subpackages;
        package_request *parent = Packaging::request_synoptic();
        <Handle the resource request 7.1>;
    }

The function Packaging::request_main is used in 19/tc (§9), 26/rt (§3), 27/ei (§3), 27/in (§2).

The function Packaging::request_resources is used in 27/ei (§3), 27/cm (§2).

The function Packaging::request_generic appears nowhere else.

The function Packaging::request_template is used in 15/ep (§4), 27/ei (§3), 27/hl (§1), 27/hr (§2.43, §6).

The function Packaging::request_synoptic appears nowhere else.

The function Packaging::initialise_subpackages is used in 27/cm (§2).

The function Packaging::request_resource is used in 5/nv (§16), 6/bp (§31), 15/pr (§27), 15/ma (§11.3), 19/tb (§9), 21/rl2 (§10), 21/fao (§10), 22/ph (§11), 22/tp (§5), 26/ts (§9.1).

The function Packaging::local_resource is used in 5/ins (§14), 20/eq (§10.1), 21/rl (§5), 24/ch (§3), 26/lt (§3).

The function Packaging::generic_resource is used in 21/ac (§6), 27/ei (§3), 27/hr (§2.2, §2.6, §2.8, §2.12, §2.20, §2.27).

The function Packaging::synoptic_resource is used in 26/jl (§3), 27/hr (§2.4, §2.10, §2.14, §2.16, §2.18, §2.21, §2.23, §2.25, §2.29, §2.31, §2.33, §2.35, §2.37, §2.39).

The structure subpackage_requests is private to this section.

§7.1. <Handle the resource request 7.1> =

        if (SR->subs[ix] == NULL) {
            text_stream *N = Hierarchy::submodule_name(ix);
            inter_name *iname = InterNames::one_off(N, parent);
            SR->subs[ix] = Packaging::request(iname, parent, plain_ptype);
        }
        return SR->subs[ix];

This code is used in §7 (three times).

§8.

    inter_name *Packaging::supply_iname(package_request *R, int what_for) {
        if (R == NULL) internal_error("no request");
        if ((what_for < 0) || (what_for >= MAX_PR_COUNTER)) internal_error("out of range");
        TEMPORARY_TEXT(P);
        switch (what_for) {
            case VERB_PR_COUNTER: WRITE_TO(P, "verb"); break;
            case MVERB_PR_COUNTER: WRITE_TO(P, "mverb"); break;
            case FUNCTION_PR_COUNTER: WRITE_TO(P, "function"); break;
            case FORM_PR_COUNTER: WRITE_TO(P, "form"); break;
            case BLOCK_PR_COUNTER: WRITE_TO(P, "code_block"); break;
            case TO_PHRASE_PR_COUNTER: WRITE_TO(P, "phrase"); break;
            case RULE_PR_COUNTER: WRITE_TO(P, "rule"); break;
            case REQUEST_PR_COUNTER: WRITE_TO(P, "request"); break;
            case CLOSURE_PR_COUNTER: WRITE_TO(P, "closure"); break;
            case RESPONSE_PR_COUNTER: WRITE_TO(P, "response"); break;
            case ADJECTIVE_PR_COUNTER: WRITE_TO(P, "adjective"); break;
            case ADJECTIVE_MEANING_PR_COUNTER: WRITE_TO(P, "adjective_meaning"); break;
            case TASK_PR_COUNTER: WRITE_TO(P, "task"); break;
            case LITERAL_PR_COUNTER: WRITE_TO(P, "literal"); break;
            case BLOCK_CONSTANT_PR_COUNTER: WRITE_TO(P, "block_constant"); break;
            case PROPOSITION_PR_COUNTER: WRITE_TO(P, "proposition"); break;
            case INSTANCE_PR_COUNTER: WRITE_TO(P, "instance"); break;
            case INLINE_PR_COUNTER: WRITE_TO(P, "inline_pval"); break;
            case PROPERTY_PR_COUNTER: WRITE_TO(P, "property"); break;
            case VARIABLE_PR_COUNTER: WRITE_TO(P, "variable"); break;
            case KIND_PR_COUNTER: WRITE_TO(P, "kind"); break;
            case ACTION_PR_COUNTER: WRITE_TO(P, "action"); break;
            case ACTIVITY_PR_COUNTER: WRITE_TO(P, "activity"); break;
            case RULEBOOK_PR_COUNTER: WRITE_TO(P, "rulebook"); break;
            case TABLE_PR_COUNTER: WRITE_TO(P, "table"); break;
            case TABLE_COLUMN_PR_COUNTER: WRITE_TO(P, "table_column"); break;
            case RELATION_PR_COUNTER: WRITE_TO(P, "relation"); break;
            case SUBSTITUTION_PR_COUNTER: WRITE_TO(P, "ts"); break;
            case SUBSTITUTIONF_PR_COUNTER: WRITE_TO(P, "ts_fn"); break;
            case MISC_PR_COUNTER: WRITE_TO(P, "misc_const"); break;
            case TEST_PR_COUNTER: WRITE_TO(P, "test"); break;
            case OUTCOME_PR_COUNTER: WRITE_TO(P, "rulebook_outcome"); break;
            case DATA_PR_COUNTER: WRITE_TO(P, "data"); break;
            case EXTERNAL_FILE_PR_COUNTER: WRITE_TO(P, "external_file"); break;
            case LABEL_STORAGE_PR_COUNTER: WRITE_TO(P, "label_associated_storage"); break;
            default: internal_error("unimplemented");
        }
        WRITE_TO(P, "_%d", ++(R->counters[what_for]));
        inter_name *iname = InterNames::one_off(P, R);
        DISCARD_TEXT(P);
        return iname;
    }

    inter_name *Packaging::function(inter_name *function_iname, package_request *R2, inter_name *temp_iname) {
        package_request *R3 = Packaging::request(function_iname, R2, function_ptype);
        inter_name *iname = InterNames::one_off(I"call", R3);
        Packaging::house(iname, R3);
        if (temp_iname) {
            TEMPORARY_TEXT(T);
            WRITE_TO(T, "%n", temp_iname);
            Inter::Symbols::set_translate(InterNames::to_symbol(iname), T);
            DISCARD_TEXT(T);
        }
        return iname;
    }

    inter_name *Packaging::function_text(inter_name *function_iname, package_request *R2, text_stream *translation) {
        package_request *R3 = Packaging::request(function_iname, R2, function_ptype);
        inter_name *iname = InterNames::one_off(I"call", R3);
        Packaging::house(iname, R3);
        if (translation) {
            Inter::Symbols::set_translate(InterNames::to_symbol(iname), translation);
        }
        return iname;
    }

    inter_name *Packaging::datum_text(inter_name *function_iname, package_request *R2, text_stream *translation) {
        package_request *R3 = Packaging::request(function_iname, R2, data_ptype);
        inter_name *iname = InterNames::one_off(translation, R3);
        Packaging::house(iname, R3);
        return iname;
    }

    void Packaging::house(inter_name *iname, package_request *at) {
        if (iname == NULL) internal_error("can't house null name");
        if (at == NULL) internal_error("can't house nowhere");
        iname->eventual_owner = at;
    }

    void Packaging::house_with(inter_name *iname, inter_name *landlord) {
        if (iname == NULL) internal_error("can't house null name");
        if (landlord == NULL) internal_error("can't house with nobody");
        iname->eventual_owner = landlord->eventual_owner;
    }

    int Packaging::houseed_in_function(inter_name *iname) {
        if (iname == NULL) return FALSE;
        if (iname->eventual_owner == NULL) return FALSE;
        if (iname->eventual_owner->eventual_type == function_ptype) return TRUE;
        return FALSE;
    }

The function Packaging::supply_iname is used in 4/am (§6), 5/ins (§14), 5/nv (§16), 6/bp (§31), 6/rlt (§15.1.2), 12/dtd (§4), 13/rsfk (§19), 15/pr (§27), 15/ma (§11.3), 17/tl (§7, §10.2.1, §14.2), 17/ts (§5), 17/rs (§5), 18/lc (§11), 19/tc (§9), 19/tb (§9), 21/rl (§5), 21/rl2 (§10), 21/fao (§10), 21/ac (§6), 22/pav (§7), 22/tp (§5, §7), 26/jl (§3), 26/ts (§9.1), 27/ei (§3, §4).

The function Packaging::function is used in 6/bp (§32), 6/rlt (§9, §9.13), 12/dtd (§4), 13/rsfk (§15), 15/ma (§11.3), 17/tl (§14.2), 17/ts (§5), 17/rs (§6.1), 20/eq (§10.1), 21/rl (§19), 21/rl2 (§10, §14), 21/ac (§8), 22/ph (§11), 22/pu (§6), 22/pav (§9), 22/tp (§7), 24/ch (§3), 26/lt (§3), 27/hl (§1).

The function Packaging::function_text is used in 21/rl (§9), 27/hl (§1).

The function Packaging::datum_text is used in 27/hl (§1).

The function Packaging::house is used in 13/rsfk (§13.1.1, §26), 15/ep (§4), 27/in (§4).

The function Packaging::house_with is used in 26/rt (§4), 27/ei (§4), 27/in (§3).

The function Packaging::houseed_in_function is used in 26/rt (§4), 27/ei (§4).