10
Types
The preceding chapter may have left you somewhat distressed. Those things that I called objects were just hash maps and were completely untyped. Anybody could stick anything into them without any constraint. The salary in the :pay-class
could hold a string instead of a number. The :schedule
field could hold an integer instead of the appropriate keyword.
In short, these objects are not statically typed. The compiler does not check them. And therefore, all hell could break loose!
Many functional languages, as well as many OO languages, are statically typed in order to prevent that hell. Other languages, like Clojure, Python, and Ruby, ...
Get Functional Design: Principles, Patterns, and Practices now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.