CSE 130 Lecture Notes - Lecture 7: Type Inference, Type Safety, Compile Time

29 views3 pages

Document Summary

Ex: apply :: (a -> b) -> a -> b: fix a function, has to return of type a", has to return of type b". Way of static analysis - checking before programs executed. Ex: insert :: k -> set k -> set k. Probably adds an element to a set, and returns a new set (since its immutable! ) Eg: reading a file readfile :: filepath -> io string. Expects a file path , a well-formatted string (/__/__*) Returns a string and also does io. Ex: obj. prop1 (prop1 is always some offset of the object in memory) Segfault (not always, if other arrays next to arr) ( runtime/hardware (os) ) Answer: depends on the language! undefined/throw exception ( runtime ) (compile time! (statically): compile-time, runtime, runtime/hardware. Return x < 10 ? x : x(); More advanced type systems can type this function. @ runtime: dynamic type checking only checks types for the path that is executing.

Get access

Grade+20% off
$8 USD/m$10 USD/m
Billed $96 USD annually
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
40 Verified Answers
Class+
$8 USD/m
Billed $96 USD annually
Class+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
30 Verified Answers

Related Documents