5cc4dcabf999519c40abf1eab4af612626507804
[ibg.git] / chapters / 14.rst
1 ======================
2 Some last lousy points
3 ======================
4
5 .. only:: html
6
7   .. image:: /images/picF.png
8      :align: left
9
10 .. raw:: latex
11
12    \dropcap{f}
13
14 inally our three example games are written; we've shown you as much of 
15 the Inform language as we've needed to, and made a lot of observations 
16 about how and why something should be done. Despite all that, there's 
17 much that we've left unsaid, or touched on only lightly. In this chapter 
18 we'll revisit key topics and review some of the more significant 
19 omissions, to give you a better feel for what's important, and what can 
20 be ignored for the time being; when you become an accomplished designer, 
21 you will decide what matters and what can be left on the shelf.
22
23 We'll also talk, in "Reading other people's code" on page 181, about a 
24 few ways of doing things that we've chosen not to tell you about, but 
25 which you're quite likely to encounter if you look at Inform code 
26 written by other designers.
27
28 The tone here is perhaps a little dry, but trust us: in walking this 
29 dusty ground we touch on just about everything that is fundamental in 
30 your overall understanding of Inform. And as always, the *Inform 
31 Designer's Manual* provides rounder and more comprehensive coverage.
32
33
34 Expressions
35 ===========
36
37 In this guide we’ve used the placeholder ``expression`` a few times; 
38 here's roughly what we mean.
39
40 * An ``expression`` is a single ``value``, or several ``values`` 
41   combined using ``operators`` and sometimes parentheses ``(...)``.
42
43 * Possible ``values`` include:
44
45   * a literal number (-32768 to 32767)
46
47   * something that's represented as a number (a character ``'a'`` , a 
48     dictionary word ``'aardvark'`` , a string ``"aardvark's adventure"`` 
49     or an action ``##Look`` )
50
51   * the internal identifier of a constant, an object, a class or a routine
52
53   * (only in a run-time statement, not in a compile-time directive) the
54     contents of a variable, or the return value from a routine.
55
56 * Possible ``operators`` include:
57
58   * an arithmetic operator: ``+ - * / % ++``
59   * a bitwise logical operator: ``& | ~``
60   * a numeric comparison operator: ``== ~= > < >= <=``
61   * an object conditional operator: ``ofclass in notin provides has hasnt``
62   * a boolean combinational operator: ``&& || ~~``
63
64
65 Internal IDs
66 ============
67
68 Many of the items which you define in your source file -- objects, 
69 variables, routines, etc. -- need to be given a name so that other items 
70 can refer to them. We call this name an item's internal identifier 
71 (because it's used only within the source file and isn't visible to the 
72 player), and we use the placeholders ``obj_id``, ``var_id``, 
73 ``routine_id``, etc. to represent where it's used. An internal ID
74
75 * can be up to thirty-two characters long
76
77 * must start with a letter or underscore, and then continue with letters 
78   ``A-Z`` , underscore ``_`` and digits ``0-9`` (where upper-case and 
79   lower-case letters are treated as indistinguishable)
80
81 * should generally be unique across all files: your source file, the 
82   standard library files, and any library contributions which you've 
83   used (except that a routine's local variables are not visible outside 
84   that routine).
85
86
87 Statements
88 ==========
89
90 A **statement** is an instruction intended for the interpreter, telling 
91 it what to do at run-time. It *must* be given in lower-case, and always 
92 ends with a semicolon.
93
94 Some statements, like ``if``, control one or more other statements. We 
95 use the placeholder ``statement_block`` to represent either a single 
96 ``statement``, or any number of ``statements`` enclosed in braces:
97
98 .. todo::
99
100   We might need some custom syntax highlighting here
101
102 .. code-block:: inform6
103
104   statement;
105
106   { statement; statement; ... statement; }
107
108 .. rubric:: Statements that we've met
109
110 Our games have used these statements, about half of the Inform 
111 possibilities:
112
113 .. code-block:: inform6
114
115   give obj_id attribute;
116   give obj_id attribute attribute ... attribute;
117
118   if (expression) statement_block
119   if (expression) statement_block else statement_block
120
121   move obj_id to parent_obj_id;
122
123   objectloop (var_id) statement_block
124
125   print value;
126   print value, value, ... value;
127
128   print_ret value;
129   print_ret value, value, ... value;
130
131   remove obj_id;
132
133   return false;
134   return true;
135
136   style underline; print...; style roman;
137
138   switch (expression) {
139       value: statement; statement; ... statement;
140       ...
141       default: statement; statement; ... statement;
142   }
143
144   "string";
145   "string", value, ... value;
146
147   <action>;
148   <action noun>;
149   <action noun second>;
150
151   <<action>>;
152   <<action noun>>;
153   <<action noun second>>;
154
155
156 .. rubric:: Statements that we've not met
157
158 Although our example games haven't needed to use them, these looping
159 statements are sometimes useful:
160
161 .. code-block:: inform6
162
163   break;
164   continue;
165
166   do statement_block until (expression)
167
168   for (set_var : loop_while_expression : update_var) statement_block
169
170   while (expression) statement_block
171
172 On the other hand, we suggest that you put the following statements on 
173 hold for now; they're not immediately relevant to everyday code and have 
174 mostly to do with printing and formatting:
175
176 .. code-block:: inform6
177
178   box
179   font
180   jump
181   new_line
182   spaces
183   string
184
185 In particular, avoid using the deprecated jump statement if you possibly can.
186
187 .. rubric:: Print rules
188
189 In ``print`` and ``print_ret`` statements, each ``value`` can be:
190
191 * a numeric ``expression``, displayed as a signed decimal number,
192
193 * a ``"string"``, displayed literally, or
194
195 * a print rule. You can create your own, or use a standard one, including:
196
197   .. tabularcolumns:: ll
198
199   +-------------------------+---------------------------------------------------+
200   | ``(a) obj_id``          | the object's name, preceded by "a", "an" or "some"|
201   +-------------------------+---------------------------------------------------+
202   | ``(A) obj_id``          | as ``(a)`` but using "A", "An" or "Some"          |
203   +-------------------------+---------------------------------------------------+
204   | ``(the) obj_id``        | the object's name, preceded by "the"              |
205   +-------------------------+---------------------------------------------------+
206   | ``(The) obj_id``        | as ``(the)`` but using "The"                      |       
207   +-------------------------+---------------------------------------------------+
208   | ``(number) expression`` | the numeric expression's value in words           |
209   +-------------------------+---------------------------------------------------+
210
211
212 Directives
213 ==========
214
215 A **directive** is an instruction intended for the compiler, telling it 
216 what to do at compile-time, while the source file is being translated 
217 into Z-code. By convention it's given an initial capital letter (though 
218 the compiler doesn't enforce this) and always ends with a semicolon.
219
220 .. rubric:: Directives that we've met
221
222 We've used all of these directives; note that for ``Class``, ``Extend``, 
223 ``Object`` and ``Verb`` the full supported syntax is more sophisticated 
224 than the basic form presented here:
225
226 .. code-block:: inform6
227
228   Class   class_id
229     with  property  value,
230           property  value,
231           ...
232           property  value,
233     has   attribute  attribute  ...  attribute;
234
235   Constant  const_id:
236   Constant  const_id = expression;
237   Constant  const_id expression;
238
239   Extend 'verb'
240       * token  token  ...  token -> action
241       * token  token  ...  token -> action
242       ...
243       * token  token  ...  token -> action
244
245   Include "filename";
246
247   Object  obj_id  "external_name"  parent_obj_id
248     with  property  value,
249           property  value,
250           ...
251           property  value,
252     has   attribute  attribute  ... attribute;
253
254   Release  expression;
255
256   Replace  routine_id;
257
258   Serial "yymmdd";
259
260   Verb  'verb'
261       * token  token  ...  token -> action
262       * token  token  ...  token -> action
263       ...
264       * token  token  ...  token -> action;
265
266   ! comment text which the compiler ignores
267
268   [ routine_id;  statement;  statement; ... statement;  ];
269
270   #Ifdef  any_id;  ... #Endif;
271
272 .. rubric:: Directives that we've not met
273
274 There's only a handful of useful directives which we haven't needed to 
275 use:
276
277 .. code-block:: inform6
278
279   Attribute attribute;
280
281   Global var_id;
282   Global var_id = expression;
283
284   Property property;
285
286   Statusline score;
287   Statusline time;
288
289 but there's a whole load which are of fairly low importance for now:
290
291 .. code-block:: inform6
292
293   Abbreviate
294   Array
295   Default
296   End
297   Ifndef
298   Ifnot
299   Iftrue
300   Iffalse
301   Import
302   Link
303   Lowstring
304   Message
305   Switches
306   System_file
307   Zcharacter
308
309 Objects
310 =======
311
312 An object is really just a collection of variables which together 
313 represent the capabilities and current status of some specific component 
314 of the model world. Full variables are called properties; simpler 
315 two-state variables are attributes.
316
317 .. rubric:: Properties
318
319 The library defines around forty-eight standard property variables (such 
320 as ``before`` or ``name``), but you can readily create further ones just 
321 by using them within an object definition.
322
323 You can create and initialise a property in an object's ``with`` segment:
324
325 .. code-block:: inform6
326
327   property,                             ! set to zero / false
328
329   property value,                       ! set to a single value
330
331   property value value ... value,       ! set to a list of values
332
333 In each case, the ``value`` is either a compile-time ``expression``, or 
334 an embedded routine:
335
336 .. code-block:: inform6
337
338   property expression,
339
340   property [; statement; statement; ... statement; ],
341
342
343 You can refer to the value of a property:
344
345 .. code-block:: inform6
346
347   self.property                         ! only within that same object
348
349   obj_id.property                       ! everywhere
350
351 and you can test whether an object definition includes a given property:
352
353 .. code-block:: inform6
354
355   (obj_id provides property)            ! is true or false
356
357
358 Routines
359 ========
360
361 Inform provides standalone routines and embedded routines.
362
363 .. rubric:: Standalone routines
364
365 Standalone routines are defined like this:
366
367 .. code-block:: inform6
368
369   [ routine_id; statement; statement; ... statement; ];
370
371 and called like this:
372
373 .. code-block:: inform6
374
375   routine_id()
376
377 .. rubric:: Embedded routines
378
379 These are embedded as the value of an object's property:
380
381 .. code-block:: inform6
382
383   property [; statement; statement; ... statement; ],
384
385 and are usually called automatically by the library, or manually by:
386
387 .. code-block:: inform6
388
389   self.property()                       ! only within that same object
390
391   obj_id.property()                     ! everywhere
392
393 .. rubric:: Arguments and local variables
394
395 Both types of routine support up to fifteen local variables -- variables 
396 which can be used only by the statements within the routine, and which 
397 are automatically initialised to zero every time that the routine is 
398 called:
399
400 .. code-block:: inform6
401
402   [ routine_id var_id var_id ... var_id; statement; statement; ... statement; ];
403
404   property [ var_id var_id ... var_id; statement; statement; ... statement; ],
405
406 You can pass up to seven arguments to a routine, by listing those 
407 arguments within the parentheses when you call the routine. The effect 
408 is simply to initialise the matching local variables to the argument 
409 values rather than to zero:
410
411 .. code-block:: inform6
412
413   routine_id(expression, expression, ... expression)
414
415 Although it works, this technique is rarely used with embedded routines, 
416 because there is no mechanism for the library to supply argument values 
417 when calling the routine.
418
419
420 .. rubric:: Return values
421
422 Every routine returns a single value, which is supplied either 
423 explicitly by some form of return statement:
424
425 .. code-block:: inform6
426
427   [ routine_id; statement; statement; ... return expr; ]; ! returns expr
428
429   property [; statement; statement; ... return expr; ], ! returns expr
430
431 or implicitly when the routine runs out of statements. If none of these 
432 ``statements`` is one -- ``return``, ``print_ret``, ``"..."` or 
433 ``<<...>>`` -- that causes an explicit return, then:
434
435 .. code-block:: inform6
436
437   [ routine_id; statement; statement; ... statement; ];
438
439 returns ``true`` and
440
441 .. code-block:: inform6
442
443   property [; statement; statement; ... statement; ]
444
445 return ``false``.
446
447 This difference is *important*. Remember it by the letter pairs STEF: 
448 left to themselves, Standalone routines return True, Embedded routines 
449 return False.
450
451 Here's an example standalone routine which returns the larger of its two
452 argument values:
453
454 .. code-block:: inform6
455
456   [ Max a b; if (a > b) return a; else return b; ];
457
458 and here are some examples of its use (note that the first example, 
459 though legal, does nothing useful whatsoever):
460
461 .. code-block:: inform6
462
463   Max(x,y);
464
465   x = Max(2,3);
466
467   if (Max(x,7) == 7) ...
468
469   switch (Max(3,y)) { ...
470
471
472 .. rubric:: Library routines versus entry points
473
474
475 A library routine is a standard routine, included within the library 
476 files, which you can optionally call from your source file if you 
477 require the functionality which the routine provides. We've mentioned 
478 these library routines:
479
480 .. code-block:: inform6
481
482   IndirectlyContains(parent_obj_id, obj_id)
483
484   PlaceInScope(obj_id)
485
486   PlayerTo(obj_id, flag)
487
488   StartDaemon(obj_id)
489
490   StopDaemon(obj_id)
491
492
493 By contrast, an entry point routine is a routine which you can provide 
494 in your source file, in which case the library calls it at an 
495 appropriate time. We've mentioned these optional entry point routines:
496
497 .. code-block:: inform6
498
499   DeathMessage()
500
501   InScope(actor_obj_id)
502
503 And this, the only mandatory one:
504
505 .. code-block:: inform6
506
507   Initialise()
508
509 There are full lists in "Library routines" on page 264 and "Optional 
510 entry points" on page 270.
511
512
513 Reading other people's code
514 ===========================
515
516 Right at the start of this guide, we warned you that we weren't setting 
517 out to be comprehensive; we've concentrated on presenting the most 
518 important aspects of Inform, as clearly as we can. However, when you 
519 read the *Inform Designer's* Manual, and more especially when you look 
520 at complete games or library extensions which other designers have 
521 produced, you'll come across other ways of doing things -- and it might 
522 be that you, like other authors, prefer them over our methods. Just try 
523 to find a style that suits you and, this is the important bit, be 
524 *consistent* about its use. In this section, we highlight some of the 
525 more obvious differences which you may encounter.
526
527 .. rubric:: Code layout
528
529 Every designer has his or her own style for laying out their source 
530 code, and they're all worse than the one you adopt. Inform's flexibility 
531 makes it easy for designers to choose a style that suits them; 
532 unfortunately, for some designers this choice seems influenced by the 
533 Jackson Pollock school of art. We've advised you to be consistent, to 
534 use plenty of white space and indentation, to choose sensible names, to 
535 add comments at difficult sections, to actively *think*, as you write 
536 your code, about making it as readable as you can.
537
538 This is doubly true if you ever contemplate sharing a library extension 
539 with the rest of the community. This example, with the name changed, is 
540 from a file in the Archive:
541
542 .. code-block:: inform6
543
544   [xxxx i j;
545   if (j==0) rtrue;
546   if (i in player) rtrue;
547   if (i has static || (i has scenery)) rtrue;
548   action=##linktake;
549   if (runroutines(j,before) ~= 0 || (j has static || (j has scenery))) {
550   print "You'll have to disconnect ",(the) i," from ",(the) j," first.^";
551   rtrue;
552   }
553   else {
554   if (runroutines(i,before)~=0 || (i has static || (i has scenery))) {
555   print "You'll have to disconnect ",(the) i," from ",(the) j," first.^";
556   rtrue;
557   }
558   else
559   if (j hasnt concealed && j hasnt static) move j to player;
560   if (i hasnt static && i hasnt concealed) move i to player;
561   action=##linktake;
562   if (runroutines(j,after) ~= 0) rtrue;
563   print "You take ",(the) i," and ",(the) j," connected to it.^";
564   rtrue;
565   }
566   ];
567
568 Here's the same routine after a few minutes spent purely on making it 
569 more comprehensible; we haven't actually tested that it (still) works, 
570 though that second ``else`` looks suspicious:
571
572 .. code-block:: inform6
573
574   [ xxxx i j;
575       if (i in player || i has static or scenery || j == nothing) return true;
576       action = ##LinkTake;
577       if (RunRoutines(j,before) || j has static or scenery)
578           "You'll have to disconnect ", (the) i, " from ", (the) j, " first.";
579       else {
580           if (RunRoutines(i,before) || i has static or scenery)
581               "You'll have to disconnect ", (the) i, " from ", (the) j, " first.";
582           else
583               if (j hasnt static or concealed) move j to player;
584           if (i hasnt static or concealed) move i to player;
585           if (RunRoutines(j,after)) return true;
586           "You take ", (the) i, " and ", (the) j, " connected to it.";
587       }
588   ];
589
590 We hope you'll agree that the result was worth the tiny extra effort. 
591 Code gets written once; it gets read dozens and dozens of times.
592
593 .. rubric:: Shortcuts
594
595 There are a few statement shortcuts, some more useful than others, which 
596 you'll come across.
597
598 * These five lines all do the same thing:
599
600   .. code-block:: inform6
601
602     return true;
603     return 1;
604     return;
605     rtrue;
606     ];          ! at the end of a standalone routine
607
608 * These four lines all do the same thing:
609
610   .. code-block:: inform6
611
612     return false;
613     return 0;
614     rfalse;
615     ];          ! at the end of an embedded routine
616
617 * These four lines all do the same thing:
618
619   .. code-block:: inform6
620
621     print "string"; new_line; return true;
622     print "string^"; return true;
623     print_ret "string";
624     "string";
625
626 * These lines are the same:
627
628   .. code-block:: inform6
629
630     print value1; print value2; print value3;
631     print value1, value2, value3;
632
633 * These lines are the same:
634
635   .. code-block:: inform6
636
637     <action noun second>; return true;
638     <<action noun second>>;
639
640 * These lines are also the same:
641
642   .. code-block:: inform6
643
644     print "^";
645     new_line;
646
647 * These ``if`` statements are equivalent:
648
649   .. code-block:: inform6
650
651     if (MyVar == 1 || MyVar == 3 || MyVar == 7) ...
652
653     if (MyVar == 1 or 3 or 7) ...
654
655 * These ``if`` statements are equivalent as well:
656
657   .. code-block:: inform6
658
659     if (MyVar ~= 1 && MyVar ~= 3 && MyVar ~= 7) ...
660     if (MyVar ~= 1 or 3 or 7) ...
661
662 * In an ``if`` statement, the thing in parentheses can be *any* 
663   expression; all that matters is its value: zero (false) or anything 
664   else (true). For example, these statements are equivalent:
665
666   .. code-block:: inform6
667
668     if (MyVar ~= false) ...
669     if (~~(MyVar == false)) ...
670     if (MyVar ~= 0) ...
671     if (~~(MyVar == 0)) ...
672     if (MyVar) ...
673
674   Note that the following statement specifically tests whether ``MyVar`` 
675   contains ``true`` (1), *not* whether its value is anything other than 
676   zero.
677
678   .. code-block:: inform6
679
680     if (MyVar == true) ...
681
682 * If ``MyVar`` is a variable, the statements ``MyVar++;`` and 
683   ``++MyVar;`` work the same as ``MyVar = MyVar + 1;`` For example, 
684   these lines are equivalent:
685
686   .. code-block:: inform6
687
688     MyVar = MyVar + 1; if (MyVar == 3) ...
689     if (++MyVar == 3) ...
690     if (MyVar++ == 2) ...
691
692   What's the same about ``MyVar++`` and ``++MyVar`` is that they both 
693   add one to ``MyVar``. What's different about them is the value to 
694   which the construct itself evaluates: ``MyVar++`` returns the current 
695   value of ``MyVar`` and then performs the increment, whereas 
696   ``++MyVar`` does the "+1" first and then returns the incremented 
697   value. In the example, if ``MyVar`` currently contains 2 then 
698   ``++MyVar`` returns 3 and ``MyVar++`` returns 2, even though in both 
699   cases the value of ``MyVar`` afterwards is 3. As another example, 
700   this code (from Helga in "William Tell"):
701
702   .. code-block:: inform6
703
704     Talk: self.times_spoken_to = self.times_spoken_to + 1;
705         switch (self.times_spoken_to) {
706             1: score = score + 1;
707                print_ret "You warmly thank Helga for the apple.";
708             2: print_ret "~See you again soon.~";
709             default: return false;
710         }
711     ],
712
713   could have been written more succinctly like this:
714
715   .. code-block:: inform6
716
717     Talk: switch (++self.times_spoken_to) {
718         1: score++;
719            print_ret "You warmly thank Helga for the apple.";
720         2: print_ret "~See you again soon.~";
721         default: return false;
722         }
723     ],
724
725 * Similarly, the statements ``MyVar--;`` and ``--MyVar;`` work the same 
726   as ``MyVar = MyVar - 1;`` Again, these lines are equivalent:
727
728   .. code-block:: inform6
729
730     MyVar = MyVar - 1; if (MyVar == 7) ...
731     if (--MyVar == 7) ...
732     if (MyVar-- == 8) ...
733
734 .. rubric:: "number" property and "general" attribute
735
736 The library defines a standard ``number`` property and a standard 
737 ``general`` attribute, whose roles are undefined: they are 
738 general-purpose variables available within every object to designers as 
739 and when they desire.
740
741 We recommend that you avoid using these two variables, primarily because 
742 their names are, by their very nature, so bland as to be largely 
743 meaningless. Your game will be clearer and easier to debug if you 
744 instead create new property variables -- with appropriate names -- as 
745 part of your ``Object`` and ``Class`` definitions.
746
747 .. rubric:: Common properties and attributes
748
749 As an alternative to creating new individual properties which apply only 
750 to a single object (or class of objects), it's possible to devise 
751 properties and new attributes which, like those defined by the library, 
752 are available on *all* objects. The need to do this is actually quite 
753 rare, and is mostly confined to library extensions (for example, the 
754 ``pname.h`` extension which we encountered in "Captain Fate: take 3" on 
755 page 147 gives every object a ``pname`` property and a 
756 ``phrase_matched`` attribute). To create them, you would use these 
757 directives near the start of your source file:
758
759 .. code-block:: inform6
760
761   Attribute attribute;
762
763   Property property;
764
765 We recommend that you avoid using these two directives unless you really 
766 do need to affect every object -- or at least the majority of them -- in 
767 your game. There is a limit of forty-eight attributes (of which the 
768 library currently defines around thirty) and sixty-two of these common 
769 properties (of which the library currently defines around forty-eight). 
770 On the other hand, the number of individual properties which you can add 
771 is virtually unlimited.
772
773 .. rubric:: Setting up the object tree
774
775 Throughout this guide, we've defined the initial position of each object 
776 within the overall object tree either by explicitly mentioning its 
777 parent's ``obj_id`` (if any) in the first line of the object definition 
778 -- what we've been calling the header information -- or, for a few 
779 objects which crop up in more than one place, by using their 
780 ``found_in`` properties. For example, in "William Tell" we defined 
781 twenty-seven objects; omitting those which used ``found_in`` to define 
782 their placement at the start of the game, we're left with object 
783 definitions starting like this:
784
785 .. code-block:: inform6
786
787   Room    street "A street in Altdorf"        
788
789   Room    below_square "Further along the street"
790   Furniture   stall "fruit and vegetable stall" below_square
791   Prop    "potatoes" below_square
792   Prop    "fruit and vegetables" below_square
793   NPC     stallholder "Helga" below_square
794
795   Room    south_square "South side of the square"
796
797   Room    mid_square "Middle of the square"
798   Furniture   pole "hat on a pole" mid_square
799
800   Room    north_square "North side of the square"
801
802   Room    marketplace "Marketplace near the square"
803   Object  tree "lime tree" marketplace
804   NPC     governor "governor" marketplace
805
806   Object  bow "bow"
807
808   Object  quiver "quiver"
809   Arrow   "arrow" quiver
810   Arrow   "arrow" quiver
811   Arrow   "arrow" quiver
812
813   Object  apple "apple"
814
815 You'll see that several of the objects begin the game as parents: 
816 ``below_square``, ``mid_square``, ``marketplace`` and ``quiver`` all 
817 have child objects beneath them; those children mention their parent as 
818 the last item of header information.
819
820 There's an alternative object syntax which is available to achieve the 
821 same object tree, using "arrows". That is, we could have defined those 
822 parent-and-child objects as:
823
824 .. code-block:: inform6
825
826   Room    below_square "Further along the street"
827   Furniture -> stall "fruit and vegetable stall"
828   Prop      -> "potatoes"
829   Prop      -> "fruit and vegetables"
830   NPC       -> stallholder "Helga"
831
832   Room      mid_square "Middle of the square"
833   Furniture   -> pole "hat on a pole"
834
835   Room      marketplace "Marketplace near the square"
836   Object    -> tree "lime tree"
837   NPC       -> governor "governor"
838
839   Object    quiver "quiver"
840   Arrow     -> "arrow"
841   Arrow     -> "arrow"
842   Arrow     -> "arrow"
843
844 The idea is that an object's header information *either* starts with an 
845 arrow, or ends with an ``obj_id``, or has neither (having both isn’t 
846 permitted). An object with neither has no parent: in this example, 
847 that's all the ``Rooms``, and also the ``bow`` and the ``quiver`` (which 
848 are moved to the player ``object`` in the ``Initialise`` routine) and 
849 the apple (which remains without a parent until Helga gives it to 
850 William).
851
852 An object which starts with a single arrow ``->`` is defined to be a 
853 child of the nearest previous object without a parent. Thus, for 
854 example, the ``tree`` and ``governor`` objects are both children of the 
855 ``marketplace``. To define a child of a child, you'd use two arrows
856 ``-> ->``, and so on. In "William Tell", that situation doesn't occur; 
857 to illustrate how it works, imagine that at the start of the game the 
858 potatoes and the other fruit and vegetables where actually *on* the 
859 stall. Then we might have used:
860
861 .. code-block:: inform6
862
863   Room    below_square "Further along the street"
864   Furniture ->  stall "fruit and vegetable stall"
865   Prop    ->  -> "potatoes"
866   Prop    ->  -> "fruit and vegetables"
867   NPC     -> stallholder "Helga"
868   ...
869
870 That is, the objects with one arrow (the ``stall`` and ``stallholder``) 
871 are children of the nearest object without a parent (the ``Room``), and 
872 the objects with two arrows (the produce) are children of the nearest 
873 object defined with a single arrow (the ``stall``).
874
875 The advantages of using arrows include:
876
877 * You're forced to define your objects in a "sensible" order.
878
879 * Fewer ``obj_ids`` may need to be used (though in this game it would 
880   make no difference).
881
882 The disadvantages include:
883
884 * The fact that objects are related by the physical juxtaposition of 
885   their definitions is not necessarily intuitive to all designers.
886
887 * Especially in a crowded room, it’s harder to be certain exactly how 
888   the various parent–child relationships are initialised, other than by 
889   carefully counting lots of arrows.
890
891 * If you relocate the parent within the initial object hierarchy to a 
892   higher or lower level, you'll need also to change its children by 
893   adding or removing arrows; this isn't necessary when the parent is 
894   named in the child headers.
895
896 We prefer to explicitly name the parent, but you'll encounter both forms 
897 very regularly.
898
899 .. rubric:: Quotes in "name" properties
900
901 We went to some lengths, way back in "Things in quotes" on page 55, to 
902 explain the difference between double quotes ``"..."`` (strings to be 
903 output) and single quotes ``'...'`` (input tokens -- dictionary words). 
904 Perhaps somewhat unfortunately, Inform allows you to blur this clean 
905 distinction: you can use double quotes in name properties and Verb 
906 directives:
907
908 .. code-block:: inform6
909
910   NPC     stallholder "Helga" below_square
911     with  name "stallholder" "greengrocer" "monger" "shopkeeper" "merchant"
912               "owner" "Helga" "dress" "scarf" "headscarf",
913   ...
914
915   Verb "talk" "t//" "converse" "chat" "gossip"
916       * "to"/"with" creature          -> Talk
917       * creature                      -> Talk;
918
919 *Please* don't do this. You'll just confuse yourself: those are 
920 dictionary words, not strings; it's just as easy -- and far clearer -- 
921 to stick rigidly to the preferred punctuation.
922
923 .. rubric:: Obsolete usages
924
925 Finally, remember that Inform has been evolving since 1993. Over that 
926 time, Graham has taken considerable care to maintain as much 
927 compatibility as possible, so that games written years ago, for earlier 
928 versions of the compiler and the library, will still compile today. 
929 While generally a good thing, this brings the disadvantage that a 
930 certain amount of obsolete baggage is still lying around. You may, for 
931 example, see games using ``Nearby`` directives (denotes parentage, 
932 roughly the same as ``->``) and ``near`` conditions (roughly, having the 
933 same parent), or with ``" \ "`` controlling line breaks in long 
934 ``print`` statements. Try to understand them; try *not* to use them.
935
936