CS 333: Assignment #5

Language Semantics

For this assignment, develop a wiki page that shows examples of I/O and exception handling. If your language has no built-in exception handling, discuss conventions and methods for catching errors in the program and handling them or exiting gracefully. Finally, develop examples of functions and how you can manipulate them.


Tasks

  1. For each of your languages, create some example programs that demonstrate reading and writing to both the terminal and to a file. Some things to consider in your examples and writeup include the following.
    • Does your language have built-in support for I/O, or is it part of a set of standard libraries?
    • Does your language support different types of files, such as binary v. text files?
    • Can the user input information into the program interactively?
    • What is the relationship between files and strings? Demonstrate similarities and differences in the way the programming language handles them.
  2. For each of your languages, create some example programs that demonstrate error and exception handling. (You have already done one of your examples for the prior homework.) Some things to consider in your examples and writeup include the following.
    • Does your language have built-in support for exception handling? If so, what are the controls structures and how do they work?
    • Are there conventions for how functions report errors? If so, what are they?
    • What are common errors in your language, and what do they mean? What went wrong?
  3. For each of your languages, create some examples of functions. Explore both the variations in the way functions and their parameters are defined and how functions are treated with respect to typing.

    For one of the examples, consider the following task. You have a set of heterogeneous things that each have a unique function that operates on them. For each thing you have a 2-element structure that contains a function and the data, and you have an array of these things. You want to loop through the array, calling the appropriate function for each thing. How would you design a system to do that in each of your languages?

    Some additional things to demonstrate include the following.

    • Is a function a data type? If so, are there limitations on what you can do with them?
    • Can you overload functions in your language? If so, what are the rules for differentiating overloaded functions?
    • If a function is not a data type, how do you pass around functionality?

Extensions


Writeup

The writeup for this week is the assignment itself, plus the code, which should be integrated with your writeup. Once you have written up your assignment, give your main page for this week the label:

cs333f10language3