News flash: I'm going to Australia in February, so this Web site may be switched off at any time.


Setting the scanning subject in Icon

When the ``e1 ? e2'' construct is used, not only is e1 established as the implicit scanning subject for the evaluation of expression e2, but there is also the idea of a current position within that subject.

Here is how an expression of the form ``e1 ? e2'' is evaluated:

  1. Expression e1 is evaluated. It should produce a string as its value.
  2. The value of e1 is stored in a predefined variable named ``&subject''.
  3. Another predefined variable named ``&pos'' is set to 1. This variable tracks the current scan position.
  4. Expression e2 is evaluated. Within any calls to string functions like ``match()'' inside expression e2, you can implicitly refer to the subject by omitting the second argument.

Next: Implicit matching in Icon
See also: Using the Icon programming language
Previous: Implicit scanning in Icon

John W. Shipman, john@nmt.edu