CIS 343

Binding and Scope

Winter 2023

Name

  1. Which of the following identifier forms is most readable? Support your decision.
    1. sumOfSales
    2. sum_of_sales
    3. SUMOFSALES
  2. In most programming languages, names may not begin with a number. Why not?
  3. What are the main disadvantages of allowing variable names to be keywords?
  4. Under what conditions would it be helpful for a language to allow variable names that are keywords?

Binding

  1. In C, the symbol `+` is bound to the addition operator at language design time.
    1. Are there any languages where the `+` symbol is bound at compile time? If so, which ones? If not, why not?
    2. Are there any languages where the `+` symbol is bound at run time. If so, which ones? If not, why not?

Type

  1. Suppose a language did not maintain any type information at all (either compile-time or run-time). Give some examples of common code snippets that simply would not work.
  2. Some languages prefix variables with clues as to the variables' types. For example, we know the Perl variable $name is a scalar of some kind. Similarly, in FORTRAN, variables named i, j, k, and l are assumed to be integers. Consider your favorite language. Would you support adding naming rules like the following? Why or why not?
(Questions in this exercise come from both Prof. Bowman and the textbook.)

Updated Monday, 3 April 2023, 9:46 AM

W3c Validation