In this assignment you'll explore both the syntax and semantics of certain types of statements in your chosen languages.
For each of your languages, complete the following tasks.
- Types: what types does the language support? Write a program that demonstrates the internal representation and limitations of two data types (e.g integers and floating point numbers).
- Operator Precedence: what are the operator precedence rules of the language? Write a program that demonstrates the operator precedence for logical (and, or, not), equality, comparison, and the standard binary and unary operators. If your language has semantic modifiers like C (& and *), include those.
- Implicit Conversion: what are the rules for implicit conversion in the language? If possible, write a program that demonstrates at least three rules for implicit conversion. Include at least one example of implicit conversion with potentially unexpected consequences. If your language does not support implicit conversion (e.g. Ada) then show examples in that language that do not work, but which would work in C.
- Scoping: what are the rules for scoping in the language? Write a program that demonstrates the properties of scoping, similar to the examples discussed in class. Is your language statically or dynamically scoped?
- Aggregate Types: what kind of aggregate types are supported by the language? In C, these would be structs and unions. In C++, you could add classes to that set. Write a program that demonstrates these structures and how to create and access them.
- Function Type: how are functions treated in the language as a data type? Can you assign a function to a variable? Can you pass a function to another function? If so, how do you then execute the function using the refrence?
- Write a program whose semantics would change depending upon the particular machine you use. Explain why in comments in your code. You are free to use one of your chosen languages or C. If you can actually find two machines with sufficiently different hardware to demonstrate your code is correct, that's a bonus. The key is to find a 32-bit machine and a 64-bit machine.
- A perfectly acceptable extension for any assignment going forward is to do a third language. C is fine.
- Choose other aspects of the language, like polymorphism, dynamic function definitions, lifetime, or aggregate data type storage and internal representation, and write example programs demonstrating those concepts.
- Explore the precedence and semantics of the C memory operators like & and *, or look at whether your languages have similar capabilities.
Make a compilable and runnable haiku in the language that helps to
demonstrate the meaning of a statement in the language.
The haiku Python def shows how the def function adds a new symbol to the computer's state which can subsequently be called.
The writeup for this week is answering the questions in assignment tasks, 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: