<ulclass="toc"><li><ahref="M-ti.html#SP1">§1. A manual of a sort</a></li><li><ahref="M-ti.html#SP3">§3. Outside even main</a></li></ul><hrclass="tocbar">
<pclass="commentary firstcommentary"><aid="SP1"class="paragraph-anchor"></a><b>§1. A manual of a sort. </b>In its textual form, Inter could conceivably be used as a programming
language, albeit a low-level and verbose one, and this section is a brief
manual for that language. But the real purpose of Inter is to assist testing
and debugging of the Inform tool-chain. We can write test cases in textual
Inter to see if inter works; or we can write out memory inter to the
each line makes a single use of a "construct" like <spanclass="extract"><spanclass="extract-syntax">package</span></span> or <spanclass="extract"><spanclass="extract-syntax">code</span></span>. Lines
can be of arbitrary length. A line beginning with a <spanclass="extract"><spanclass="extract-syntax">#</span></span> (in column 1) is
<pclass="commentary">A convention followed in Inter code generated by Inform is that many identifiers
have the form <spanclass="extract"><spanclass="extract-syntax">P_Name</span></span>, where <spanclass="extract"><spanclass="extract-syntax">P</span></span> is some prefix letter showing what sort of
thing is referred to: for example, variables begin with <spanclass="extract"><spanclass="extract-syntax">V</span></span>, instances with <spanclass="extract"><spanclass="extract-syntax">I</span></span>,
properties with <spanclass="extract"><spanclass="extract-syntax">P</span></span>, and so on. This is all done only for clarity, and is not
<pclass="commentary firstcommentary"><aid="SP2"class="paragraph-anchor"></a><b>§2. </b>The main organising idea of Inter is the "package". Each program is a nested
hierarchy of packages, and each package has both a name and a "package type".
In the <spanclass="extract"><spanclass="extract-syntax">Hello</span></span> example, an outer package called <spanclass="extract"><spanclass="extract-syntax">main</span></span>, of type <spanclass="extract"><spanclass="extract-syntax">_plain</span></span>,
holds only a inner package called <spanclass="extract"><spanclass="extract-syntax">Main</span></span>, of type <spanclass="extract"><spanclass="extract-syntax">_code</span></span>.
<pclass="commentary">In fact, every program must contain just one outermost package, called <spanclass="extract"><spanclass="extract-syntax">main</span></span>,
which has to have type <spanclass="extract"><spanclass="extract-syntax">_plain</span></span>, so that is unsurprising.
<pclass="commentary">Packages of type <spanclass="extract"><spanclass="extract-syntax">_code</span></span> are functions. A program is not required to contain any
functions at all, and even if it does, it is not required to contain one called
<spanclass="extract"><spanclass="extract-syntax">Main</span></span>. For example, the Inter program into which BasicInformKit is compiled
does not provide a <spanclass="extract"><spanclass="extract-syntax">Main</span></span>, and we could imagine kits which provided, say, only
some variables and arrays. But if we want a program to compile and run in a
stand-alone way, then it needs a <spanclass="extract"><spanclass="extract-syntax">Main</span></span> function as a place to begin running.
<pclass="commentary firstcommentary"><aid="SP3"class="paragraph-anchor"></a><b>§3. Outside even main. </b>Though this does not happen in the <spanclass="extract"><spanclass="extract-syntax">Hello</span></span> example, a handful of instructions
can appear at the top of the program, outside even <spanclass="extract"><spanclass="extract-syntax">main</span></span>. These really just
define conventions used in the rest of the program, rather than describing
what the program does, and that is why they are on the outside.
<pclass="commentary firstcommentary"><aid="SP4"class="paragraph-anchor"></a><b>§4. </b><spanclass="extract"><spanclass="extract-syntax">version NUMBER</span></span> indicates that the file was written in that version of
the Inter language. <spanclass="extract"><spanclass="extract-syntax">NUMBER</span></span> is a semantic version number, and it forces
<ahref="index.html"class="internal">inter</a> to reject the file if the version of the Inter specification
understood by <ahref="index.html"class="internal">inter</a> is not compatible with the one in the file. (Note
that this about the version of the specification, not the version of <ahref="index.html"class="internal">inter</a>
<pclass="commentary">See <ahref="../bytecode-module/1-tiv.html"class="internal">The Inter Version (in bytecode)</a> for more on the significance of this.
<pclass="commentary firstcommentary"><aid="SP5"class="paragraph-anchor"></a><b>§5. </b><spanclass="extract"><spanclass="extract-syntax">pragma TARGET "WHATEVER"</span></span> does not change the meaning of the inter file;
<pclass="commentary firstcommentary"><aid="SP6"class="paragraph-anchor"></a><b>§6. </b><spanclass="extract"><spanclass="extract-syntax">packagetype _NAME</span></span> declares that <spanclass="extract"><spanclass="extract-syntax">_NAME</span></span> can be used as a package type.
It's actually unnecessary to write this explicitly, which is why the <spanclass="extract"><spanclass="extract-syntax">Hello</span></span>
<pclass="commentary">If the program creates, say, <spanclass="extract"><spanclass="extract-syntax">package MOMA _museum</span></span>, then the necessary
package type instruction <spanclass="extract"><spanclass="extract-syntax">packagetype _museum</span></span> will be inferred automatically.
<pclass="commentary">All package types have names beginning with an underscore <spanclass="extract"><spanclass="extract-syntax">_</span></span>. Authors of
Inter programs are free to choose any types they like, and Inform tends to
use semantically meaningful type names like <spanclass="extract"><spanclass="extract-syntax">_adjective</span></span>. Only two package
types are special: <spanclass="extract"><spanclass="extract-syntax">_code</span></span>, which as we have seen marks that a package is a
function, and <spanclass="extract"><spanclass="extract-syntax">_linkage</span></span>, which is used only for a special package called
<spanclass="extract"><spanclass="extract-syntax">connectors</span></span>. Stand-alone programs never contain that package: see
<pclass="commentary firstcommentary"><aid="SP7"class="paragraph-anchor"></a><b>§7. </b><spanclass="extract"><spanclass="extract-syntax">primitive !PRIMITIVE SIGNATURE</span></span> declares that a primitive invocation of
this name and signature can be used in the program. Primitives occur only
inside of functions, where they are "invoked", and they are operations
sufficiently basic that they cannot themselves be written as other Inter
functions. For example, in <spanclass="extract"><spanclass="extract-syntax">Hello</span></span> we saw:
<pclass="commentary">This is an invocation of the primitive <spanclass="extract"><spanclass="extract-syntax">!print</span></span>, which prints text. The
"signature" of this is <spanclass="extract"><spanclass="extract-syntax">val -> void</span></span>, meaning that it expects to have one
<pclass="commentary">The declarations for the two primitives in <spanclass="extract"><spanclass="extract-syntax">Hello</span></span> would look like this:
<pclass="commentary firstcommentary"><aid="SP8"class="paragraph-anchor"></a><b>§8. </b>The declaration line for a package begins at the level of indentation of
the package's owner. For <spanclass="extract"><spanclass="extract-syntax">main</span></span>, it should be unindented, and this is the
only package allowed to appear at the top level: all other packages should
be inside <spanclass="extract"><spanclass="extract-syntax">main</span></span> in some way.
<pclass="commentary">Here, <spanclass="extract"><spanclass="extract-syntax">main</span></span> contains two sub-packages, <spanclass="extract"><spanclass="extract-syntax">m1_RBLK1</span></span> and <spanclass="extract"><spanclass="extract-syntax">m1_RBLK2</span></span>, and
indentation is used to show which package a statement belongs to.
<pclass="commentary">Here, <spanclass="extract"><spanclass="extract-syntax">inner_part</span></span> cannot be made a subpackage of <spanclass="extract"><spanclass="extract-syntax">my_function</span></span> because <spanclass="extract"><spanclass="extract-syntax">_code</span></span>
<pclass="commentary firstcommentary"><aid="SP9"class="paragraph-anchor"></a><b>§9. </b>The remaining statements to cover fall into two categories.
<ulclass="items"><li>● Those used outside functions, i.e., packages of type <spanclass="extract"><spanclass="extract-syntax">_code</span></span>, are covered in
<ahref="M-dpiti.html"class="internal">Data Packages in Textual Inter</a>.
</li><li>● Those used in functions, i.e., packages of type <spanclass="extract"><spanclass="extract-syntax">_code</span></span>, are covered in
<ahref="M-cpiti.html"class="internal">Code Packages in Textual Inter</a>.