Next / Previous / Contents / Shipman's homepage

5.4. Useful metaphors: identity and “anything”

Certain metaphors are useful in constructing compound intended functions.


The identity transform. Used as the consequence of an “if” or “else” clause when there are no state changes in that case.

Here's an example:

    # To survive in a cubicle farm, keep your head below the top of
    # the partition. (-hp- folklore ca. 1974)
    # [ if height > wall.maxHeight ->
    #     height  :=  wall.maxHeight
    #   else ->
    #     I ]
    height = min(height, wall.maxHeight)

The intended function says that if height <= wall.maxHeight, nothing changes.

... := (anything)

If you specify that the new value of a state item is “(anything)”, you are saying that the value of that state item is unreliable or unimportant.

Here's an example. Suppose that your script is supposed to update a file named bio-file, but in some error conditions, it messes up the contents of the file. We might write the intended function for the script in this way:

# [ if new-data file is valid ->
#      file bio-file  :=  file bio-file updated using new-data
#      sys.stderr  +:=  message indicating success
#    else ->
#      file bio-file  :=  (anything)
#      sys.stderr  +:=  message indicating failure ]