Skip to main content

Part of the book series: Undergraduate Topics in Computer Science ((UTICS))

  • 5200 Accesses

Abstract

Lexing and parsing will reject many texts as not being correct programs. However, many languages have well-formedness requirements that can not be handled exclusively by the techniques seen so far. These requirements can, for example, be static type correctness or a requirement that pattern-matching or case-statements are exhaustive. These properties are most often not context-free, i.e., they can not be checked by membership of a context-free language. Consequently, they are checked by a phase that (conceptually) comes after syntax analysis (though it may be interleaved with it). These checks may happen in a phase that does nothing else, or they may be combined with the actual execution or translation to another language. Often, the translator may exploit or depend on type information, which makes it natural to combine calculation of types with the actual translation. In Chap. 4, we covered type-checking during execution, which is normally called dynamic typing. We will in this chapter assume that type checking and related checks are done in a phase previous to execution or translation (i.e., static typing), and similarly assume that any information gathered by this phase is available in subsequent phases.

“The most touching epitaph I ever encountered was on the tombstone of the printer of Edinburgh. It said simply:

He kept down the cost and set the type right.”

Gregory Nunn (1955–)

This is a preview of subscription content, log in via an institution to check access.

Access this chapter

Chapter
USD 29.95
Price excludes VAT (USA)
  • Available as PDF
  • Read on any device
  • Instant download
  • Own it forever
eBook
USD 29.99
Price excludes VAT (USA)
  • Available as EPUB and PDF
  • Read on any device
  • Instant download
  • Own it forever

Tax calculation will be finalised at checkout

Purchases are for personal use only

Institutional subscriptions

Notes

  1. 1.

    Unlike in Chap. 4, where the error function stops execution.

References

  1. Aho, A.V., Lam, M.S., Sethi, R., Ullman, J.D.: Compilers; Principles, Techniques and Tools. Addison-Wesley, Reading (2007)

    Google Scholar 

  2. Milner, R.: A theory of type polymorphism in programming. J. Comput. Syst. Sci. 17(3), 348–375 (1978)

    Article  MathSciNet  MATH  Google Scholar 

Download references

Author information

Authors and Affiliations

Authors

Corresponding author

Correspondence to Torben Ægidius Mogensen .

Rights and permissions

Reprints and permissions

Copyright information

© 2011 Springer-Verlag London Limited

About this chapter

Cite this chapter

Mogensen, T.Æ. (2011). Type Checking. In: Introduction to Compiler Design. Undergraduate Topics in Computer Science. Springer, London. https://doi.org/10.1007/978-0-85729-829-4_5

Download citation

  • DOI: https://doi.org/10.1007/978-0-85729-829-4_5

  • Publisher Name: Springer, London

  • Print ISBN: 978-0-85729-828-7

  • Online ISBN: 978-0-85729-829-4

  • eBook Packages: Computer ScienceComputer Science (R0)

Publish with us

Policies and ethics