CSE 1729 Lecture 23: CSE 1729 - Lecture 23 - Object Oriented Programming (2)

92 views2 pages
Verified Note

Document Summary

: makes the destructive assignment but doesn"t make a new: like return binding. Oop example: (define (make-hidden-value initial-value) (let ((value initial-value)) (define (mult-by x) (begin (set! Value (* value x)) (value)) (define (add-to y) (begin (set! Value (+ value y)) (value)) (cons (mult-by add-to))) Follow it during an execution: function-pair: (m . a, m is mult-by, a is add-to. token values: single quote and some identifier, to see if the 2 tokens are the same, we use the eq? function, eq? tests for identity quality, are these 2 the exact identity. Bank account example: idea: establish an environment in which balance lives. Objects: implemented in scheme by defining an object creator, the creator builds an environment containing the private state variables of the object, it returns a function (which references these local variables in its body). Remnant) #f) ((eq? x (car remnant)) #t) (else (member-iter (cdr remnant))))) (member-iter s-list)) (define (insert x) (set!

Get access

Grade+
$40 USD/m
Billed monthly
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
10 Verified Answers
Class+
$30 USD/m
Billed monthly
Class+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
7 Verified Answers

Related Documents