Name
- Which of the following identifier forms is most readable? Support your decision.
sumOfSales
sum_of_sales
SUMOFSALES
- In most programming languages, names may not begin with a number. Why not?
- What are the main disadvantages of allowing variable names to be keywords?
- Under what conditions would it be helpful for a language to allow variable names that are keywords?
Binding
- In C, the symbol `+` is bound to the addition operator at language design time.
- Are there any languages where the `+` symbol is bound at compile time? If so, which ones? If not, why not?
- Are there any languages where the `+` symbol is bound at run time. If so, which ones? If not, why not?
Type
- 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.
- 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?
- integer variable names must start with
i
- floating-point variable names must start with
f
- and so on ...
Why or why not?
(Questions in this exercise come from both Prof. Bowman and the textbook.)
Updated Monday, 3 April 2023, 9:46 AM