Linguistic theory can in some cases be applied to modify programming languages and to describe how programmers understand computer programs while reading program source code. So-called object-oriented programming languages are used to represent semantic relationships between objects and their parts and this knowledge can be used in indirect anaphors written in these programming languages. Anaphors in programming languages parallel anaphors in natural language: in the sentences “The lecturer opened the laptop. The screen lit up, the lecturer was ready.”, both the direct anaphor “the lecturer” and the indirect anaphor “the screen” are understood easily. Because readers typically know that a laptop has a screen, they typically understand that “the screen” refers to the screen of the laptop mentioned in the first sentence. Because such part-of relations are available in object-oriented programming languages, indirect anaphors can be used in object-oriented programming. Programmers could thereby avoid having to re-state well-known relationships between parts and wholes. While this eases reading and writing for those programmers who know the part-of relation underspecified through the use of an indirect anaphor, it complicates reading for those who do not know the part-of relation.
Psycholinguists have investigated direct and indirect anaphors in natural language already. To get an initial understanding of how programmers read and comprehend direct and indirect anaphors in program source code and to see when programmers do (not) understand indirect anaphors, I constructed and performed an eye-tracking experiment during which programmers read source code that contained direct and indirect anaphors. Good comprehension was operationalized by means of short task durations and like in studies from psycholinguistics as short gaze and regression durations and good performance on comprehension questions. I report the experimental results for these measures and outline possible improvements to the experimental design and to anaphors in programming languages.