[Skip Navigation] [CSUSB] / [CNS] / [CSE] / [R J Botting] /[CS320 Course Materials] /06q.html [06q.txt(Text)] [Search ]
Thu Apr 19 13:54:15 PDT 2012
[Schedule] [Syllabi] [Text] [Labs] [Projects] [Resources] [Grading] [Contact]
Notes: [01] [02] [03] [04] [05] [06] [07] [08] [09] [10] [11] [12] [13] [14] [15] [16] [17] [18] [19] [20]

Contents


    CS320/06 Questions on Chapter 5

      Question 1

      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.

      Question 2 Static vs dynamic scoping

      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.

      Question 3

      Storage bindings. In C++ how do you create the following types of storage:
      1. a. static storage that holds one int
      2. b. stack-dynamic storage that holds one int
      3. c. explicit heap-dynamic storage that holds one int

      How are following kinds of storage in C++ deallocated?

      1. d. stack-dynamic storage
      2. e. explicit heap-dynamic storage

      Question 4 -- Unicode or ASCII variables

      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?

      Project

      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

      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.

    Review

    Think back over this class and grade your personal performance in terms of how much work you need to do on this topic before the final.

End