Top Banner
1 Pointers and Expressions Prof. Evan Chang Meeting 16, CSCI 3155, Fall 2009 Announcements HW5 due Thu Oct 22 at 11:55pm How was Project 1? How are recitations? 2 Finish Unions Unions What are they for? Kinds of unions? 4 Unions 5 Exercise Define types and code for evaluating an expression language in C (and in SML): e ::= n | -e | e + e | e * e 6
5

Pointers and Expressions - cs.colorado.edubec/courses/csci3155-f09/slides/meeting16... · Pointers and Expressions Prof. Evan Chang Meeting 16, CSCI 3155, Fall 2009 Announcements

May 30, 2020

Download

Documents

dariahiddleston
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Pointers and Expressions - cs.colorado.edubec/courses/csci3155-f09/slides/meeting16... · Pointers and Expressions Prof. Evan Chang Meeting 16, CSCI 3155, Fall 2009 Announcements

1

Pointers and Expressions

Prof. Evan Chang

Meeting 16, CSCI 3155, Fall 2009

Announcements

• HW5 due Thu Oct 22 at 11:55pm

• How was Project 1?

• How are recitations?

2

Finish Unions

Unions

• What are they for?

• Kinds of unions?

4

Unions

5

Exercise

• Define types and code for evaluating an expression language in C (and in SML):

e ::= n | -e | e + e | e * e

6

Page 2: Pointers and Expressions - cs.colorado.edubec/courses/csci3155-f09/slides/meeting16... · Pointers and Expressions Prof. Evan Chang Meeting 16, CSCI 3155, Fall 2009 Announcements

2

Pointers

Pointers

• Dangling pointer bug

• Memory leak bug

8

Pointers

• A pointer type include values that range over memory addresses

• ... and often an additional distinguished value null.

– “The Billion Dollar Mistake”

9

Pointers

• A pointer type include values that range over memory addresses

• ... and often an additional distinguished value null.– SML analog?

10

Pointer Operations

• What are they?

11

Problem: Dangling Pointer

• What is it?

12

Page 3: Pointers and Expressions - cs.colorado.edubec/courses/csci3155-f09/slides/meeting16... · Pointers and Expressions Prof. Evan Chang Meeting 16, CSCI 3155, Fall 2009 Announcements

3

Problem: Dangling Pointer

• What is it?

13

Problem: Dangling Pointer

• What problems can it cause?

14

Problem: Dangling Pointer

• What problems can it cause?

15

Problem: Dangling Pointer

• Possible solutions?

16

Problem: Memory Leak

• What is it?

17

Problem: Memory Leak

• What is it?

18

Page 4: Pointers and Expressions - cs.colorado.edubec/courses/csci3155-f09/slides/meeting16... · Pointers and Expressions Prof. Evan Chang Meeting 16, CSCI 3155, Fall 2009 Announcements

4

Problem: Memory Leak

• What problems can it cause?

19

Problem: Memory Leak

• What problems can it cause?

20

Problem: Memory Leak

• Possible solutions?

21

Garbage Collection

22

Garbage Collection: Reference Counting

23

Garbage Collection: Reference Counting

24

Page 5: Pointers and Expressions - cs.colorado.edubec/courses/csci3155-f09/slides/meeting16... · Pointers and Expressions Prof. Evan Chang Meeting 16, CSCI 3155, Fall 2009 Announcements

5

Garbage Collection: Reference Counting

25

Garbage Collection: Mark-and-Sweep

26

For Next Time

• Reading

• Online discussion forum– ≥1 substantive question, comment, or answer each week

• Work on HW3

27