Pointers

Wherever an object or a location label can be used, so too can a number of special purpose pointers. When a command referring to a pointer is processed, the pointer will be substituted with the label of the item that it currently points to. This avoids the repetition of code and its assoicated problems of efficiency and consistency. As a real-world example, imagine an instruction that says, "call Rimmer," compared to one that says "call whoever is specified on the yellow note stuck on the fridge". The second instruction doesn't give an explicit person to call, instead it gives a pointer to where the name can be found. The advantage to this is that the person to be called can be changed regularly without any need to modify the instruction. Pointers in JACL are exactly the same as that yellow note stuck on the fridge. Except they're not yellow. Or stuck on the fridge.

Below is a function demonstrating the use of pointers:


   {+where_is
   write "<ul>"
   loop
      if noun3 hasnt LOCATION
         noun4 = noun3(parent)
         write "<li> "noun3{The} 
         write " is in " noun4{the} ^
      endif
   endloop
   write "<ul>"
   }

The above function loops through all the objects defined in the game and displays their current whereabouts. The loop command automatically sets the pointer noun3, while the general purpose pointer noun4 is manually set to each object's parent.

The two tables below detail each of the available object and location pointers:

Object Pointers

Pointer Description
player This pointer is set to the object that currently represents the player in the game.
noun1 This pointer is set to the first object referred to in the player's last move.
noun2 This pointer is set to the second object referred to in the player's last move.
noun3 This pointer is set to the first object in the game whenever a loop command is encountered. It will then be incremented to point to the next object each time an endloop command is encountered.
noun4 This pointer is never modified by the JACL interpreter or the any code in the library. It is therefore free for use by the author.

Location Pointers

Pointer Description
here This pointer represents the location that the player is currently in. It is synonymous to the element player(parent).
destination This represents the location that the player is attempting to move into. The value of destination can be tested in the +movement function before the move is completed. Once the move is complete, destination will equal here until the next move is attempted. This is a read-only pointer and therefore cannot be used as the container parameter of a set command.
Be sure your code can never make a reference to a pointer that does not point to a valid object or location. This can sometimes make for a bug that is very hard to track down.