Class 20: Type checking, continued
Held Wednesday, October 14, 1998
- Nathaniel Borenstein will be visiting campus the first two weeks
of the second half of this semester.
- As part of his visit, he
is giving the convocation speech on October 29th. Typically,
students are invited to a post-convocation lunch. If you are
interested in attending that lunch, please let Mr. Walker know.
very rough draft of his schedule is available online.
- There are a few small typos on the exam which most of you figured out.
- In the last problem of the Java version, two page numbers are reversed.
- In the C version, when it refers to "red book", read "green book".
- In the last problem of the C version, where it says "put", read "S_enter".
- Recall that there are three things we want to do while type-checking:
- Verify that all types are used correctly (e.g., that only integers
- Determine the types of expressions. This is necessary to verify that
types are used correctly, since most expressions have subexpressions.
For example, when we assign to a variable, we need to determine the
types of both the variable and the assigned expression.
- Verify that all identifiers are declared before use.
- As is the case for other stages of the compiler, we'd like our
type checker to be able to continue processing even after an
error is encountered.
- For most expressions, it is possible to pick a ``default'' type,
even when there is a conflict.
- If the explicit type and expression type for a function or
variable differ, report an error and use the explicit type.
- If a variable is undeclared, either naively assume that it's
an integer or determine its type from context (the latter is
harder to do, as you may need to pass an ``expected type'' into
the type checking mechanism).
- If an arithmetic operator is applied to two subexpressions, assume
the type of the arithmetic expression is integer.
- For some of the following, we'll summarize the expected
check that is done.
- Note that we can do some error recovery along the way
- Array constants
- Record constants
- Function calls
- Operator application
- For loops
- Let expressions
- We focused on array and record-related issues, including
recovering variables from the previous class.
- Created Wednesday, October 14, 1998. Some portion of the outline
was taken from the previous day's outline.
- On Friday, October 16, 1998, I moved the majority of the outline to
the subsequent outline. Also added the introductory note on type-checking.
Disclaimer Often, these pages were created "on the fly" with little, if any, proofreading. Any or all of the information on the pages may be incorrect. Please contact me if you notice errors.
Source text last modified Fri Oct 16 10:25:53 1998.
This page generated on Fri Oct 16 10:34:54 1998 by SiteWeaver.
Contact our webmaster at firstname.lastname@example.org