A simple algorithm to decipher declarations

  • Authors:
  • Thomas E. Carpenter, Jr.

  • Affiliations:
  • Computer Science and Software Engineering, Seattle University, Seattle, Washington

  • Venue:
  • Journal of Computing Sciences in Colleges
  • Year:
  • 2003

Quantified Score

Hi-index 0.00

Visualization

Abstract

It is often the case that key, fundamental concepts and/or programming techniques are very quickly covered (and forgotten) in the curriculum. This is true of the concept of precedence, and with type declarations. Usually, students are presented with the canonical a+b*c example in order to illustrate the difference in precedence between the addition and multiplication operators, then given a quick glance at the precedence table, and, finally, told to parenthesize when in doubt. Students typically, and understandably, have difficulties when learning about declarations and definitions of variables, and have difficulty learning the syntax to decipher and construct types on their own. This paper presents a simple algorithm to decipher types in the C and C++ languages that illustrates to students that, by understanding the precedence of the operators used in declarations, they can deconstruct and understand complex declarations easily. It is useful in showing the importance of precedence, in clearing up the confusion over declarations, and in higher-level classes such as Operating Systems.