Lecture overview -- Keyboard shortcut: 'u'  Previous page: Functions and closures revisited -- Keyboard shortcut: 'p'  Next page: A general pattern of classes -- Keyboard shortcut: 'n'  Lecture notes - all slides and notes together  slide -- Keyboard shortcut: 't'  Help page about these notes  Alphabetic index  Course home  Lecture 3 - Page 3 : 43
Programming Paradigms
Simulation of other Paradigms and Continuations
Classes and objects

Due to (1) the first class status of functions, and due to (2) the use of static binding of free names, it is possible to interpret a closure as an object

With this interpretation, it is possible to regard certain function definitions as classes

  • Object model:

    • Objects are instances of classes

    • Objects interact by means of message passing

    • Methods are dynamically looked up (in the classes behind the objects)

      • All methods are virtual

c:/Users/Kurt/Teaching-material/Pp-Scheme-17/notes/includes/point-all.scmThe definition of a 'class Point ' with methods getx , gety , add , and type-of.

On this page we have also defined the syntactical convenience function send that sends a message to an object. In Racket be sure that you define send before Point (such that send in the add method refers to our send , and not an already existing and unrelated definition of the name send ).

c:/Users/Kurt/Teaching-material/Pp-Scheme-17/notes/includes/point-all.scmThe send method which is used in the Point class.

The function apply calls a function on a list of parameters. This should be seen in contrast to a normal call, in which the individual parameters are passed.

Go to exercisePoints and Rectangle