1
0
Fork 0
mirror of https://github.com/ganelson/inform.git synced 2024-07-03 07:24:58 +03:00
inform7/docs/inter/M-ip.html

351 lines
30 KiB
HTML

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Inform Primitives</title>
<link href="../docs-assets/Breadcrumbs.css" rel="stylesheet" rev="stylesheet" type="text/css">
<meta name="viewport" content="width=device-width initial-scale=1">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta http-equiv="Content-Language" content="en-gb">
<link href="../docs-assets/Contents.css" rel="stylesheet" rev="stylesheet" type="text/css">
<link href="../docs-assets/Progress.css" rel="stylesheet" rev="stylesheet" type="text/css">
<link href="../docs-assets/Navigation.css" rel="stylesheet" rev="stylesheet" type="text/css">
<link href="../docs-assets/Fonts.css" rel="stylesheet" rev="stylesheet" type="text/css">
<link href="../docs-assets/Base.css" rel="stylesheet" rev="stylesheet" type="text/css">
<link href="../docs-assets/Colours.css" rel="stylesheet" rev="stylesheet" type="text/css">
</head>
<body class="commentary-font">
<nav role="navigation">
<h1><a href="../index.html">
<img src="../docs-assets/Inform.png" height=72">
</a></h1>
<ul><li><a href="../compiler.html">compiler tools</a></li>
<li><a href="../other.html">other tools</a></li>
<li><a href="../extensions.html">extensions and kits</a></li>
<li><a href="../units.html">unit test tools</a></li>
</ul><h2>Compiler Webs</h2><ul>
<li><a href="../inbuild/index.html">inbuild</a></li>
<li><a href="../inform7/index.html">inform7</a></li>
<li><a href="index.html"><span class="selectedlink">inter</span></a></li>
</ul><h2>Inbuild Modules</h2><ul>
<li><a href="../supervisor-module/index.html">supervisor</a></li>
</ul><h2>Inform7 Modules</h2><ul>
<li><a href="../core-module/index.html">core</a></li>
<li><a href="../assertions-module/index.html">assertions</a></li>
<li><a href="../values-module/index.html">values</a></li>
<li><a href="../knowledge-module/index.html">knowledge</a></li>
<li><a href="../imperative-module/index.html">imperative</a></li>
<li><a href="../runtime-module/index.html">runtime</a></li>
<li><a href="../if-module/index.html">if</a></li>
<li><a href="../multimedia-module/index.html">multimedia</a></li>
<li><a href="../index-module/index.html">index</a></li>
</ul><h2>Inter Modules</h2><ul>
<li><a href="../bytecode-module/index.html">bytecode</a></li>
<li><a href="../building-module/index.html">building</a></li>
<li><a href="../pipeline-module/index.html">pipeline</a></li>
<li><a href="../final-module/index.html">final</a></li>
</ul><h2>Services</h2><ul>
<li><a href="../arch-module/index.html">arch</a></li>
<li><a href="../calculus-module/index.html">calculus</a></li>
<li><a href="../html-module/index.html">html</a></li>
<li><a href="../inflections-module/index.html">inflections</a></li>
<li><a href="../kinds-module/index.html">kinds</a></li>
<li><a href="../linguistics-module/index.html">linguistics</a></li>
<li><a href="../problems-module/index.html">problems</a></li>
<li><a href="../syntax-module/index.html">syntax</a></li>
<li><a href="../words-module/index.html">words</a></li>
<li><a href="../../../inweb/docs/foundation-module/index.html">foundation</a></li>
</ul>
</nav>
<main role="main">
<!--Weave of 'Inform Primitives' generated by Inweb-->
<div class="breadcrumbs">
<ul class="crumbs"><li><a href="../index.html">Home</a></li><li><a href="../compiler.html">Compiler Tools</a></li><li><a href="index.html">inter</a></li><li><a href="index.html#M">Manual</a></li><li><b>Inform Primitives</b></li></ul></div>
<p class="purpose">The standard set of primitive invocations used within Inform.</p>
<ul class="toc"><li><a href="M-ip.html#SP1">&#167;1. Status</a></li><li><a href="M-ip.html#SP2">&#167;2. Arithmetic</a></li><li><a href="M-ip.html#SP3">&#167;3. Logical operators</a></li><li><a href="M-ip.html#SP4">&#167;4. Bitwise operators</a></li><li><a href="M-ip.html#SP5">&#167;5. Numerical comparison</a></li><li><a href="M-ip.html#SP6">&#167;6. Sequential evaluation</a></li><li><a href="M-ip.html#SP7">&#167;7. Random numbers</a></li><li><a href="M-ip.html#SP8">&#167;8. Printing</a></li><li><a href="M-ip.html#SP9">&#167;9. Stack access</a></li><li><a href="M-ip.html#SP10">&#167;10. Accessing storage</a></li><li><a href="M-ip.html#SP11">&#167;11. Indirect function calls</a></li><li><a href="M-ip.html#SP12">&#167;12. Control flow</a></li><li><a href="M-ip.html#SP13">&#167;13. Interactive fiction-only primitives</a></li></ul><hr class="tocbar">
<p class="commentary firstcommentary"><a id="SP1" class="paragraph-anchor"></a><b>&#167;1. Status. </b>The Inter specification allows for any number of primitive invocations to
be declared and used; none are built-in or required.
</p>
<p class="commentary">The Inform compiler, however, has a set of around 90 different primitives.
The back end of the compiler can compile those into valid Inform 6 code;
the front end of the compiler is guaranteed to declare and use only (a
subset of) those 90. That gives the following set of primitives a
kind of halfway status: though they are not part of the inter specification,
for the time being they're the only game in town.
</p>
<p class="commentary firstcommentary"><a id="SP2" class="paragraph-anchor"></a><b>&#167;2. Arithmetic. </b>The following are standard integer arithmetic operations:
</p>
<ul class="items"><li>(a) <span class="extract"><span class="extract-syntax">primitive !plus val val -&gt; val</span></span>. 16 or 32-bit integer addition.
</li><li>(b) <span class="extract"><span class="extract-syntax">primitive !minus val val -&gt; val</span></span>. 16 or 32-bit integer subtraction.
</li><li>(c) <span class="extract"><span class="extract-syntax">primitive !unaryminus val -&gt; val</span></span>. Equivalent to performing <span class="extract"><span class="extract-syntax">0 - x</span></span>.
</li><li>(d) <span class="extract"><span class="extract-syntax">primitive !times val val -&gt; val</span></span>. 16 or 32-bit integer multiplication.
</li><li>(e) <span class="extract"><span class="extract-syntax">primitive !divide val val -&gt; val</span></span>. 16 or 32-bit integer division.
</li><li>(f) <span class="extract"><span class="extract-syntax">primitive !modulo val val -&gt; val</span></span>. Remainder after such a division.
</li></ul>
<p class="commentary firstcommentary"><a id="SP3" class="paragraph-anchor"></a><b>&#167;3. Logical operators. </b>In general, the value 0 is false, and all other values are true.
</p>
<ul class="items"><li>(a) <span class="extract"><span class="extract-syntax">primitive !not val -&gt; val</span></span>. True if the value is false, and vice versa.
</li><li>(b) <span class="extract"><span class="extract-syntax">primitive !and val val -&gt; val</span></span>. True if both are true: doesn't evaluate the second if the first is false.
</li><li>(c) <span class="extract"><span class="extract-syntax">primitive !or val val -&gt; val</span></span>. True if either is true: doesn't evaluate the second if the first is true.
</li></ul>
<p class="commentary firstcommentary"><a id="SP4" class="paragraph-anchor"></a><b>&#167;4. Bitwise operators. </b>These differ in that they do not "short circuit", and do not squash values
down to just 0 or 1.
</p>
<ul class="items"><li>(a) <span class="extract"><span class="extract-syntax">primitive !bitwiseand val val -&gt; val</span></span>.
</li><li>(a) <span class="extract"><span class="extract-syntax">primitive !bitwiseor val val -&gt; val</span></span>.
</li><li>(a) <span class="extract"><span class="extract-syntax">primitive !bitwisenot val -&gt; val</span></span>.
</li></ul>
<p class="commentary firstcommentary"><a id="SP5" class="paragraph-anchor"></a><b>&#167;5. Numerical comparison. </b>These are comparisons of signed integers. (If Inform needs to compare unsigned
integers, it calls a routine in the I6 template.)
</p>
<ul class="items"><li>(a) <span class="extract"><span class="extract-syntax">primitive !eq val val -&gt; val</span></span>.
</li><li>(b) <span class="extract"><span class="extract-syntax">primitive !ne val val -&gt; val</span></span>.
</li><li>(c) <span class="extract"><span class="extract-syntax">primitive !gt val val -&gt; val</span></span>.
</li><li>(d) <span class="extract"><span class="extract-syntax">primitive !ge val val -&gt; val</span></span>.
</li><li>(e) <span class="extract"><span class="extract-syntax">primitive !lt val val -&gt; val</span></span>.
</li><li>(f) <span class="extract"><span class="extract-syntax">primitive !le val val -&gt; val</span></span>.
</li></ul>
<p class="commentary firstcommentary"><a id="SP6" class="paragraph-anchor"></a><b>&#167;6. Sequential evaluation. </b>The reason for the existence of <span class="extract"><span class="extract-syntax">!ternarysequential</span></span> is that it's a convenient
shorthand, and also that it helps the code generator with I6 generation,
because I6 has problems with the syntax of complicated sequential evals.
</p>
<ul class="items"><li>(a) <span class="extract"><span class="extract-syntax">primitive !sequential val val -&gt; val</span></span>. Evaluates the first, then the second
value, producing that second value.
</li><li>(a) <span class="extract"><span class="extract-syntax">primitive !ternarysequential val val val -&gt; val</span></span>. Evaluates the first,
then the second, then the third value, producing that third value.
</li></ul>
<p class="commentary firstcommentary"><a id="SP7" class="paragraph-anchor"></a><b>&#167;7. Random numbers. </b>There is just one primitive for this:
</p>
<ul class="items"><li>(a) <span class="extract"><span class="extract-syntax">primitive !random val -&gt; val</span></span>. Produce a uniformly random integer in the range 0 up to <span class="extract"><span class="extract-syntax">val</span></span> minus 1.
</li></ul>
<p class="commentary firstcommentary"><a id="SP8" class="paragraph-anchor"></a><b>&#167;8. Printing. </b>These print data of various kinds:
</p>
<ul class="items"><li>(a) <span class="extract"><span class="extract-syntax">primitive !print val -&gt; void</span></span>. Print text.
</li><li>(b) <span class="extract"><span class="extract-syntax">primitive !printnumber val -&gt; void</span></span>. Print a (signed) number in decimal.
</li><li>(c) <span class="extract"><span class="extract-syntax">primitive !printchar val -&gt; void</span></span>. Print a character value, from the ZSCII character set.
</li><li>(d) <span class="extract"><span class="extract-syntax">primitive !printaddress val -&gt; void</span></span>. Print a dictionary word.
</li><li>(e) <span class="extract"><span class="extract-syntax">primitive !printstring val -&gt; void</span></span>. Print a packed string.
</li></ul>
<p class="commentary">While these correspond to standard I6 library functions, they should probably
be removed from the set of primitives, but there are issues here to do with
the Inform 6 "veneer":
</p>
<ul class="items"><li>(a) <span class="extract"><span class="extract-syntax">primitive !printnlnumber val -&gt; void</span></span>. Print number but in natural language.
</li><li>(b) <span class="extract"><span class="extract-syntax">primitive !printname val -&gt; void</span></span>. Print name of an object.
</li><li>(c) <span class="extract"><span class="extract-syntax">primitive !printdef val -&gt; void</span></span>. Print name of an object, preceded by definite article.
</li><li>(d) <span class="extract"><span class="extract-syntax">primitive !printcdef val -&gt; void</span></span>. Print name of an object, preceded by capitalised definite article.
</li><li>(e) <span class="extract"><span class="extract-syntax">primitive !printindef val -&gt; void</span></span>. Print name of an object, preceded by indefinite article.
</li><li>(f) <span class="extract"><span class="extract-syntax">primitive !printcindef val -&gt; void</span></span>. Print name of an object, preceded by capitalised indefinite article.
</li></ul>
<p class="commentary">There are also primitive ways to change the visual style of text:
</p>
<ul class="items"><li>(a) <span class="extract"><span class="extract-syntax">primitive !font val -&gt; void</span></span>. Change to fixed-width font if value is 1, or regular if 0.
</li><li>(b) <span class="extract"><span class="extract-syntax">primitive !stylebold void -&gt; void</span></span>. Change to bold type.
</li><li>(c) <span class="extract"><span class="extract-syntax">primitive !styleunderline void -&gt; void</span></span>. Change to underlined type.
</li><li>(d) <span class="extract"><span class="extract-syntax">primitive !styleroman void -&gt; void</span></span>. Change to roman (i.e., not bold, not underlined) type.
</li></ul>
<p class="commentary">Lastly, a primitive for a rum feature of Inform 6 allowing for the display of
"box quotations" on screen:
</p>
<ul class="items"><li>(a) <span class="extract"><span class="extract-syntax">primitive !box val -&gt; void</span></span>.
</li></ul>
<p class="commentary firstcommentary"><a id="SP9" class="paragraph-anchor"></a><b>&#167;9. Stack access. </b>The stack is not directly accessible anywhere in memory, so the only access
is via the following.
</p>
<ul class="items"><li>(a) <span class="extract"><span class="extract-syntax">primitive !push val -&gt; void</span></span>. Push value onto the stack.
</li><li>(b) <span class="extract"><span class="extract-syntax">primitive !pull ref -&gt; void</span></span>. Pull value from the stack and write it into
the storage referred to. Values on the stack have unchecked kinds: it's up to
the author not to pull an inappropriate value.
</li></ul>
<p class="commentary firstcommentary"><a id="SP10" class="paragraph-anchor"></a><b>&#167;10. Accessing storage. </b>Here the <span class="extract"><span class="extract-syntax">ref</span></span> term is a refernce to a piece of storage: a property of an
instance, or a global variable, or an entry in memory, for example.
</p>
<ul class="items"><li>(a) <span class="extract"><span class="extract-syntax">primitive !store ref val -&gt; val</span></span>. Put the value in <span class="extract"><span class="extract-syntax">ref</span></span>.
</li><li>(b) <span class="extract"><span class="extract-syntax">primitive !setbit ref val -&gt; void</span></span>. Set bits in the mask <span class="extract"><span class="extract-syntax">val</span></span> in <span class="extract"><span class="extract-syntax">ref</span></span>.
</li><li>(c) <span class="extract"><span class="extract-syntax">primitive !clearbit ref val -&gt; void</span></span>. Clear bits in the mask <span class="extract"><span class="extract-syntax">val</span></span> in <span class="extract"><span class="extract-syntax">ref</span></span>.
</li><li>(d) <span class="extract"><span class="extract-syntax">primitive !postincrement ref -&gt; val</span></span>. Performs the equivalent of <span class="extract"><span class="extract-syntax">ref++</span></span>.
</li><li>(e) <span class="extract"><span class="extract-syntax">primitive !preincrement ref -&gt; val</span></span>. Performs the equivalent of <span class="extract"><span class="extract-syntax">++ref</span></span>.
</li><li>(f) <span class="extract"><span class="extract-syntax">primitive !postdecrement ref -&gt; val</span></span>. Performs the equivalent of <span class="extract"><span class="extract-syntax">ref--</span></span>.
</li><li>(g) <span class="extract"><span class="extract-syntax">primitive !predecrement ref -&gt; val</span></span>. Performs the equivalent of <span class="extract"><span class="extract-syntax">--ref</span></span>.
</li></ul>
<p class="commentary">Memory can be read with the following. The first value is the address of
the array; the second is an offset, that is, with 0 being the first entry,
1 the second, and so on. "Word" in this context means either an <span class="extract"><span class="extract-syntax">int16</span></span> or
an <span class="extract"><span class="extract-syntax">int32</span></span>, depending on what virtual machine are compiling to.
</p>
<ul class="items"><li>(a) <span class="extract"><span class="extract-syntax">primitive !lookup val val -&gt; val</span></span>. Find word at this word offset.
</li><li>(b) <span class="extract"><span class="extract-syntax">primitive !lookupbyte val val -&gt; val</span></span>. Find byte at this byte offset.
</li></ul>
<p class="commentary">Those however only read from array entries. To write to array entries, we
need to use <span class="extract"><span class="extract-syntax">!store</span></span> or similar (see above); but to do that, we need a
reference for the memory cell. We do that with:
</p>
<ul class="items"><li>(a) <span class="extract"><span class="extract-syntax">primitive !lookupref val val -&gt; ref</span></span>.
</li></ul>
<p class="commentary">(There is at present no equivalent for byte arrays.)
</p>
<p class="commentary firstcommentary"><a id="SP11" class="paragraph-anchor"></a><b>&#167;11. Indirect function calls. </b>Invocations of functions can only be made with <span class="extract"><span class="extract-syntax">inv</span></span> when the function is
specified as a constant, and when its signature is therefore known. If
we need to call "whatever function this variable refers to", we have to
use one of the following. They differ only in their signatures. The
first value is the function address, and subsequent ones are arguments.
</p>
<ul class="items"><li>(a) <span class="extract"><span class="extract-syntax">primitive !indirect0v val -&gt; void</span></span>.
</li><li>(b) <span class="extract"><span class="extract-syntax">primitive !indirect1v val val -&gt; void</span></span>.
</li><li>(c) <span class="extract"><span class="extract-syntax">primitive !indirect2v val val val -&gt; void</span></span>.
</li><li>(d) <span class="extract"><span class="extract-syntax">primitive !indirect3v val val val val -&gt; void</span></span>.
</li><li>(e) <span class="extract"><span class="extract-syntax">primitive !indirect4v val val val val val -&gt; void</span></span>.
</li><li>(f) <span class="extract"><span class="extract-syntax">primitive !indirect5v val val val val val val -&gt; void</span></span>.
</li><li>(g) <span class="extract"><span class="extract-syntax">primitive !indirect0 val -&gt; val</span></span>.
</li><li>(h) <span class="extract"><span class="extract-syntax">primitive !indirect1 val val -&gt; val</span></span>.
</li><li>(i) <span class="extract"><span class="extract-syntax">primitive !indirect2 val val val -&gt; val</span></span>.
</li><li>(j) <span class="extract"><span class="extract-syntax">primitive !indirect3 val val val val -&gt; val</span></span>.
</li><li>(k) <span class="extract"><span class="extract-syntax">primitive !indirect4 val val val val val -&gt; val</span></span>.
</li><li>(l) <span class="extract"><span class="extract-syntax">primitive !indirect5 val val val val val val -&gt; val</span></span>.
</li></ul>
<p class="commentary firstcommentary"><a id="SP12" class="paragraph-anchor"></a><b>&#167;12. Control flow. </b>The simplest control statement is an "if". Note that a different primitive
is used if there is an "else" attached: it would be impossible to use the
same primitive for both because they couldn't have the same signature.
</p>
<p class="commentary"><span class="extract"><span class="extract-syntax">!ifdebug</span></span> is an oddity: it executes the code only if the program is
being compiled in "debugging mode". (In Inform, that would mean that the
story file is being made inside the application, or else released in a
special testing configuration.) While the same effect could be achieved
using conditional compliation splats, this is much more efficient.
</p>
<ul class="items"><li>(a) <span class="extract"><span class="extract-syntax">primitive !if val code -&gt; void</span></span>.
</li><li>(b) <span class="extract"><span class="extract-syntax">primitive !ifelse val code code -&gt; void</span></span>.
</li><li>(c) <span class="extract"><span class="extract-syntax">primitive !ifdebug code -&gt; void</span></span>.
</li></ul>
<p class="commentary">There are then several loops.
</p>
<ul class="items"><li>(a) <span class="extract"><span class="extract-syntax">primitive !while val code -&gt; void</span></span>. Similar to <span class="extract"><span class="extract-syntax">while</span></span> in C.
</li><li>(b) <span class="extract"><span class="extract-syntax">primitive !for val val val code -&gt; void</span></span>. Similar to <span class="extract"><span class="extract-syntax">for</span></span> in C.
</li><li>(c) <span class="extract"><span class="extract-syntax">primitive !objectloopx ref val code -&gt; void</span></span>. A loop over instances,
stored in the variable <span class="extract"><span class="extract-syntax">ref</span></span>, of the kind of object <span class="extract"><span class="extract-syntax">val</span></span>.
</li><li>(d) <span class="extract"><span class="extract-syntax">primitive !objectloop ref val val code -&gt; void</span></span>. A more general form,
where the secomd <span class="extract"><span class="extract-syntax">val</span></span> is a condition to be evaluated which decides whether
to execute the code for given <span class="extract"><span class="extract-syntax">ref</span></span> value.
</li></ul>
<p class="commentary">A switch statement takes a value, and then executes at most one of an
arbitrary number of possible code segments. This can't be implemented with
a single primitive, because its signature would have to be of varying
lengths with different uses (since some switches have many cases, some few).
Instead: a <span class="extract"><span class="extract-syntax">switch</span></span> takes a single <span class="extract"><span class="extract-syntax">code</span></span>, but that <span class="extract"><span class="extract-syntax">code</span></span> can in turn
contain only invocations of <span class="extract"><span class="extract-syntax">!case</span></span>, followed optionally by one of <span class="extract"><span class="extract-syntax">!default</span></span>.
</p>
<ul class="items"><li>(a) <span class="extract"><span class="extract-syntax">primitive !switch val code -&gt; void</span></span>.
</li><li>(b) <span class="extract"><span class="extract-syntax">primitive !case val code -&gt; void</span></span>.
</li><li>(c) <span class="extract"><span class="extract-syntax">primitive !default code -&gt; void</span></span>.
</li></ul>
<p class="commentary">This looks a little baroque, but it works in practice:
</p>
<pre class="displayed-code all-displayed-code code-font">
<span class="plain-syntax"> </span><span class="reserved-syntax">inv</span><span class="plain-syntax"> </span><span class="function-syntax">!switch</span>
<span class="plain-syntax"> </span><span class="reserved-syntax">val</span><span class="plain-syntax"> </span><span class="identifier-syntax">K_number</span><span class="plain-syntax"> X</span>
<span class="plain-syntax"> </span><span class="reserved-syntax">code</span>
<span class="plain-syntax"> </span><span class="reserved-syntax">inv</span><span class="plain-syntax"> </span><span class="function-syntax">!case</span>
<span class="plain-syntax"> </span><span class="reserved-syntax">val</span><span class="plain-syntax"> </span><span class="identifier-syntax">K_number</span><span class="plain-syntax"> </span><span class="constant-syntax">1</span>
<span class="plain-syntax"> </span><span class="reserved-syntax">code</span>
<span class="plain-syntax"> </span><span class="reserved-syntax">inv</span><span class="plain-syntax"> </span><span class="function-syntax">!print</span>
<span class="plain-syntax"> </span><span class="reserved-syntax">val</span><span class="plain-syntax"> </span><span class="identifier-syntax">K_text</span><span class="plain-syntax"> </span><span class="string-syntax">"One!"</span>
<span class="plain-syntax"> </span><span class="reserved-syntax">inv</span><span class="plain-syntax"> </span><span class="function-syntax">!case</span>
<span class="plain-syntax"> </span><span class="reserved-syntax">val</span><span class="plain-syntax"> </span><span class="identifier-syntax">K_number</span><span class="plain-syntax"> </span><span class="constant-syntax">2</span>
<span class="plain-syntax"> </span><span class="reserved-syntax">code</span>
<span class="plain-syntax"> </span><span class="reserved-syntax">inv</span><span class="plain-syntax"> </span><span class="function-syntax">!print</span>
<span class="plain-syntax"> </span><span class="reserved-syntax">val</span><span class="plain-syntax"> </span><span class="identifier-syntax">K_text</span><span class="plain-syntax"> </span><span class="string-syntax">"Two!"</span>
<span class="plain-syntax"> </span><span class="reserved-syntax">inv</span><span class="plain-syntax"> </span><span class="function-syntax">!default</span>
<span class="plain-syntax"> </span><span class="reserved-syntax">code</span>
<span class="plain-syntax"> </span><span class="reserved-syntax">inv</span><span class="plain-syntax"> </span><span class="function-syntax">!print</span>
<span class="plain-syntax"> </span><span class="reserved-syntax">val</span><span class="plain-syntax"> </span><span class="identifier-syntax">K_text</span><span class="plain-syntax"> </span><span class="string-syntax">"Something else!"</span>
</pre>
<p class="commentary">As in most C-like languages, there are primitives for:
</p>
<ul class="items"><li>(a) <span class="extract"><span class="extract-syntax">primitive !break void -&gt; void</span></span>. Exit the innermost switch case or loop.
</li><li>(b) <span class="extract"><span class="extract-syntax">primitive !continue void -&gt; void</span></span>. Complete the current iteration of
the innermost loop.
</li></ul>
<p class="commentary">Two ways to terminate what's happening:
</p>
<ul class="items"><li>(a) <span class="extract"><span class="extract-syntax">primitive !return val -&gt; void</span></span>. Finish the current function, giving the
supplied value as the result if the function is being executed in a value
context, and throwing it away if not.
</li><li>(b) <span class="extract"><span class="extract-syntax">primitive !quit void -&gt; void</span></span>. Halt the whole program immediately.
</li></ul>
<p class="commentary">And, lastly, the lowest-level way to travel:
</p>
<ul class="items"><li>(a) <span class="extract"><span class="extract-syntax">primitive !jump lab -&gt; void</span></span>. Jumo to this label in the current function.
</li></ul>
<p class="commentary firstcommentary"><a id="SP13" class="paragraph-anchor"></a><b>&#167;13. Interactive fiction-only primitives. </b>The following would make no sense in a general-purpose program. Most mirror
very low-level I6 features, and Inform uses them mainly when converting
I6 code into inter: in almost all cases it's better to call routines in the
template rather than to use these. First, the spatial containment object tree:
</p>
<ul class="items"><li>(a) <span class="extract"><span class="extract-syntax">primitive !move val val -&gt; void</span></span>. Moves first to second (both are objects).
</li><li>(b) <span class="extract"><span class="extract-syntax">primitive !in val val -&gt; val</span></span>. Tests if first is in second (both are objects).
</li><li>(c) <span class="extract"><span class="extract-syntax">primitive !notin val val -&gt; val</span></span>. Negation of same.
</li></ul>
<p class="commentary">Object class membership:
</p>
<ul class="items"><li>(a) <span class="extract"><span class="extract-syntax">primitive !ofclass val val -&gt; val</span></span>. Does the first belong to the enumerated
subkind whose weak type ID is the second value?
</li></ul>
<p class="commentary">Attributes can be handled as follows. The values used to refer to these attributes
can be inter symbols for their properties, but only if those properties are
indeed stored as Z-machine or Glulx attributes at run-time.
</p>
<ul class="items"><li>(a) <span class="extract"><span class="extract-syntax">primitive !give val val -&gt; void</span></span>. Set the second (an attribute) for the first (an object).
</li><li>(b) <span class="extract"><span class="extract-syntax">primitive !take val val -&gt; void</span></span>. Unset the second (an attribute) for the first (an object).
</li><li>(c) <span class="extract"><span class="extract-syntax">primitive !has val val -&gt; val</span></span>. Test if the first (an object) has the second (an attibute).
</li><li>(d) <span class="extract"><span class="extract-syntax">primitive !hasnt val val -&gt; val</span></span>. Negation of same.
</li></ul>
<p class="commentary">Direct access to virtual machine object properties:
</p>
<ul class="items"><li>(a) <span class="extract"><span class="extract-syntax">primitive !propertyvalue val val -&gt; val</span></span>.
</li><li>(b) <span class="extract"><span class="extract-syntax">primitive !propertyaddress val val -&gt; val</span></span>.
</li><li>(c) <span class="extract"><span class="extract-syntax">primitive !propertylength val val -&gt; val</span></span>.
</li><li>(d) <span class="extract"><span class="extract-syntax">primitive !provides val val -&gt; val</span></span>.
</li></ul>
<nav role="progress"><div class="progresscontainer">
<ul class="progressbar"><li class="progressprev"><a href="M-cpiti.html">&#10094;</a></li><li class="progresscurrentchapter">M</li><li class="progresssection"><a href="M-ui.html">ui</a></li><li class="progresssection"><a href="M-ti.html">ti</a></li><li class="progresssection"><a href="M-dpiti.html">dpiti</a></li><li class="progresssection"><a href="M-cpiti.html">cpiti</a></li><li class="progresscurrent">ip</li><li class="progresssection"><a href="M-ia.html">ia</a></li><li class="progresssection"><a href="M-io.html">io</a></li><li class="progresssection"><a href="M-pas.html">pas</a></li><li class="progresssection"><a href="M-rc.html">rc</a></li><li class="progresschapter"><a href="1-mn.html">1</a></li><li class="progressnext"><a href="M-ia.html">&#10095;</a></li></ul></div>
</nav><!--End of weave-->
</main>
</body>
</html>