Scoping rules determine how a particular occurrence of a variable
matches to the appropriate binding. There are two types of scoping
rules: static scoping and dynamic scoping. In static scoping, a
variable always refers to its nearest enclosing binding. On the
other hand, dynamic scoping is based on the calling sequence but not on
the spatial relationships.
In this homework, you will compare the scoping rules in four
mykeyword for lexical scope and
localkeyword for dynamic scope.
Write programs for the same test example in four different languages to clearly illustrate the different scoping rules used by these languages. You are encouraged to come up with an example that emphasizes the advantages and limitations of both scoping rules.
To help the TAs give you good grades, appropriately comment your source to explain your example and why your example is an appropriate one for this homework.
Make sure your programs execute in the dijkstra.cs.bilkent.edu.tr machine, since the TA will test your programs on this machine.
Place your example programs under different files each having your last name and
name, and a description for the language and scoping used.
lastname_name_php.php (or lastname_name_php.html).
Also, write a report to compare all the programs that you have
written. Copy the programs into the report (with the comments when
necessary), explain what scoping rule is used in that example, if
possible write the output or explain the program execution.
You may use the tutorials available in the Internet as a reference, but do not derive your example from the contents of the tutorials. If you do so, your programs may be similar to others in the class, that causes a disciplinary investigation.
Put your report and example files under a folder named lastname_name and make a zip or rar of the folder. Then e-mail this file to the TA, Alper Erošlu < email@example.com >.
Collaboration on the homework is not allowed.
Suggestion: Do not postpone the execution of your programs to the last minute!. The disjkstra machnine might be overloaded, then.