CPSC 210 Lecture Notes - Lecture 4: Turing Award, Joshua Bloch, Postcondition

60 views12 pages
11 Aug 2016
School
Course

Document Summary

Many object-oriented programming languages use type hierarchies and polymorphism to simplify the expression of software. Each piece of data a software program creates or uses has a type that de nes the operations that can be performed on that piece of data. Some programming languages infer the type of a piece of data. For instance, in scheme, you could write a function to calculate the cost of a bus trip if you need to buy n tickets as: (define (cost-of-bus-trip n) (* 2. 50 n)) This function attempts to treat the value passed as a parameter (i. e. n) as a number because it is used in an operation (*) that operates on numbers. If a string is passed, as in (cost-of-bus-trip ), the interpreter will complain that the expected type of n is a number. In other programming languages, such as java, each variable used in a program must have a type declared by the programmer.

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