teaching machines

CS 330 Lecture 20 – Weak Typing in C

Agenda

  • what ?s
  • weak typing examples
    • array allocation
    • big endian
    • is negative check for floats
    • unions
  • “polymorphism” in C

TODO

  • The midterm exam will be during class next Wednesday. General topics we’ve covered include the shell, regular expressions, grammars, abstract syntax trees, the mechanics of assembly, and type systems through the lens of C. Exam questions are designed to use knowledge gained from homework and synthesize ideas. I’m not so interested in you having memorized a bunch of facts or API. See the past semesters’ exams under the Teaching tab.

Note

Today¬†we’ll look to some examples of weak typing in C, in which we undermine the type system to do some sometimes perfectly reasonable things. We’ll see why arrays traditionally couldn’t be allocated on the stack via consts, how to do a runtime check for the endianness of a processor, how we can check the negativity of a float, and how one might support a limited form of polymorphism for data structures.

Code

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *