env_stuff - ; Allison Coates' notes: ; CS61A ; State, local...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
;;; Allison Coates' notes: ;;; CS61A ;;; State, local state variables, environments ;;; Written 17 July 2001 ;;; Moral rights owned by A Coates. ;;; Permission to use notes for research, ;;; academic and personal is permitted ONLY with the above citation ;;; pf my work and moral rights. No fee may be charged. .. ;;; motivation: ;;; the elements needed to implement OOP: ;;; local state, methods, assignment/mutation, inheritance ;;; we need a new way to do that: ;;; turns out, we'll be able to do it using ;;; everything from before, and one additional primitive: ;;; set! ;;; BUT we need a new way of THINKING abuot what's going on. ;;; but more that that (define (roots a b c) (define (roots1 d) (/ (+ (- b ) d) (* 2 a))) (roots1 (sqrt (- (* b b) (* 4 a c))))) (define roots2 (lambda (a b c) (define (roots2-1 d) (/ (+ (- b) d) (* 2 a))) (roots2-1 (sqrt (- (* b b) (* 4 a c)))))) ;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;; below we have (define (foo) (define bar 1)) ;;; the above is really THIS: ;;; (define foo (lambda () (define bar 1)))
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 4

env_stuff - ; Allison Coates' notes: ; CS61A ; State, local...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online