CSC148H5 Lecture 3: Lecture 3

50 views1 pages
1 Apr 2018
School
Course

Document Summary

Calling s. pop() on an empty stack s evaluating x = 3 / Approach #1: return error code in some languages (e. g. , c), functions return special values to signify errors. E. g. , unix functions return -1 to mean error concerns with this approach: It requires you to check the return value of every function you call. This changes the flow of the program it assumes there is an appropriate error value to return that won"t be confused with a real return value! In return_error_code. py, when the randomly generated d = 5, the correct return value is -1, which is confused with the error code! Caught by an exception handler somewhere along the line, or your program will crash. Exceptions allow you to structure code in a natural way so that error handling and recovery are isolated from the regular flow of your program. (we will see why).

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