236 Chapter 5 Names, Bindings, and Scopes
- Describe the encapsulation of an F# let inside a function and outside all
functions. - What are the advantages and disadvantages of dynamic scoping?
- What are the advantages of named constants?
PROBLEM SET
- Which of the following identifier forms is most readable? Support your
decision.
SumOfSales
sum_of_sales
SUMOFSALES - Some programming languages are typeless. What are the obvious advan-
tages and disadvantages of having no types in a language? - Write a simple assignment statement with one arithmetic operator in some
language you know. For each component of the statement, list the various
bindings that are required to determine the semantics when the statement is
executed. For each binding, indicate the binding time used for the language. - Dynamic type binding is closely related to implicit heap-dynamic vari-
ables. Explain this relationship. - Describe a situation when a history-sensitive variable in a subprogram is
useful. - Consider the following JavaScript skeletal program:
// The main program
var x;
function sub1() {
var x;
function sub2() {
...
}
}
function sub3() {
...
}
Assume that the execution of this program is in the following unit order:
main calls sub1
sub1 calls sub2
sub2 calls sub3