1a. Give short definitions of each of the following: reserved word,
keyword, case sensitive, binding, binding time, static binding, dynamic
binding, lifetime, and scope.
1b. Draw a big diagram using the UML that shows a binding between a Variable
and its Value.
Hint -- USE PENCIL.
2a. What does this C++ program output:
#include <iostream>
using namespace std;
int i =1;
void f(int n){ cout <<n <<": "<< i; }
int main()
{ int i=2;
f(3);
}
Fill in the blank: This output shows that C++ functions use ____________
scoping.
[ 06ex.cpp ]
2b. What does this C++ program output:
#include <iostream>
using namespace std;
int i =1;
#define f(n) {cout <<n <<": "<< i;}
int main()
{ int i=2;
f(3);
}
Fill in the blank: This output shows that a C++ macro (#define) uses
____________ scoping.
2c. Define static scoping and dynamic scoping.
2d. Compare the advantages and disadvantages of these two scoping methods.
Storage bindings. In C++ how do you create the following types of storage:
- a. static storage that holds one int
- b. stack-dynamic storage that holds one int
- c. explicit heap-dynamic storage that holds one int
How are following kinds of storage in C++ deallocated?
- d. stack-dynamic storage
- e. explicit heap-dynamic storage
4a. Visit
[ ffba3b61cd0a821e?hl=en ]
(Google group discussing Python) on whether we should use Unicode rather than ASCII
when we design a language.
4b. Report back to class with your conclusions -- Unicode or ASCII? And WHY?
You are designing a new language. You must decide (and justify) the issues
and options raised in this chapter on names. Will your language be
sensitive to case? (why?). Will you have reserved words or key words?
(Why?) What is the scope of a variable? Will it be resolved statically or
dynamically? (WHY!)
Answers to questions 1, 3, and 4 should be checked against the book. Check
2 online and in the book. You invent your own answers for the project.