Lecture overview -- Keyboard shortcut: 'u'  Previous page: Classes and objects in Scheme [Section] -- Keyboard shortcut: 'p'  Next page: Classes and objects -- Keyboard shortcut: 'n'  Lecture notes - all slides together  Annotated slide -- Keyboard shortcut: 't'  Textbook -- Keyboard shortcut: 'v'  Alphabetic index  Help page about these notes  Course home    Object-oriented programming in Scheme - slide 4 : 11

Functions with private context
It is possible to define a private context around a function
(define function-with-private-context
 (let (CONTEXT)
   (lambda (PARAMETERS)
      BODY)))
Expression

Value

(define document
 (let
   ((html 
     (xml-modify-element html 
      'xmlns "http://www.w3.org/1999/xhtml"))
    (body 
     (xml-modify-element body 
      'bgcolor (rgb-color-encoding 255 0 0)))
      )
   (lambda (ttl bdy)
    (html
      (head (title ttl))
      (body bdy)))))
 
(document "A title" "A body")
<html xmlns = 
       "http://www.w3.org/1999/xhtml">
 <head>
  <title>A title</title>
 </head> 
 <body bgcolor = "#ff0000">
  A body
 </body>
</html>