CSE 130 Lecture Notes - Lecture 14: Exception Handling, Donald Knuth, Computable Function
39 views4 pages
Dijkstra’s “Go To” criticism
-go-to’s are BAD
-new high-level control flow constructs
-why is it bad?
-there is NO structure! You can basically jump anywhere
- we don’t know WHERE we will end up!
1. Eliminate gotos in some cases
2. Add gotos in other cases (i.e. in controlled form)
- Helps simplify code (can jump to labels for error checking, for example)
-a paradigm - has things like “control flow” statements
-includes things like control structures, procedures, blocks, etc.
- Makes code less gnarly (easier to write)
- Helps simplify certain areas where there can be potential faults
Programming w/ Gotos
-largely unstructured control flow graphs
-Control flow graphs (CFG) - graphs that describe “control flow”, where programs go, can lead
to, and flow from
What constructs do we need to express ANY computable function?
A: sequencing of instructions, selection (aka conditional branching), iteration (looping)
CFG of sequencing
→ | | → | | jump, or branch
CFG of if-else
→ | | → | A | → | |
→ | B | → | C |
If A then __
CFG of “do” - while loop
→ | | → exit
← loop back around