Assignment - Assignments and Procs w/Params Click to edit...

Info icon This preview shows pages 1–9. Sign up to view the full content.

View Full Document Right Arrow Icon
Click to edit Master subtitle style cs784(tk) L123Assg Assignments and Procs w/Params 11
Image of page 1

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

View Full Document Right Arrow Icon
cs784(tk) L123Assg Assignment, LHS := RHS l-value: left-, location, address, reference, r-value: right-, int, real, address, … env and store allow one to describe the semantics of assignment in a purely functional style. (DENOTATIONAL SEMANTICS) Object language structures are mapped to similar Scheme structures. (META- 22
Image of page 2
cs784(tk) L123Assg Sharing sharing/aliasing Point p = new Point(); Point q = p; call by reference void f(Point p){…}; f(q); 33
Image of page 3

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

View Full Document Right Arrow Icon
cs784(tk) L123Assg Side-effects in Scheme Update variable: (set! var exp) denotes location denotes value In Scheme locations are denotable, but not expressible Sequencing: (begin exp1 exp2 … expn) Ordering of expressions important 44
Image of page 4
cs784(tk) L123Assg Expressible vs. Denotable values Expressible Values the language can express and compute these represented in the language's syntax as expressions Denotable Values represented in syntax by declarations the names and their values saved within a data structure (called a namespace or environment or symbol table or activation record) CS784 55 SchemeRefresher
Image of page 5

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

View Full Document Right Arrow Icon
cs784(tk) L123Assg Expressible vs. Denotable values Booleans are expressible in (early) FORTRAN, but not denotable. Functions are denotable in many languages, but are not expressible. In (functional subset of) Scheme, both value spaces are identical. In (full) Scheme, variable references (pointers) are denotable but not expressible. CS784 66 SchemeRefresher
Image of page 6
cs784(tk) L123Assg Local Binding: let ( let proc-id ([ id init-expr ] ...) body ...+) Defines a local procedure. Evaluates the init-expr s; these become arguments to the proc. The id s must be distinct. (let fac ([n 10]) (if (zero? n) 1 (* n (fac (sub1 n))))) m 3628800 CS784 77 SchemeRefresher
Image of page 7

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

View Full Document Right Arrow Icon
cs784(tk) L123Assg Local Binding: let* ( let* ([ id val-expr ] ...) body ...+) Similar to let , but evaluates the val-expr s one by one, creating a location for each id as soon as the value is available.
Image of page 8
Image of page 9
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern