[plt-scheme] Parameters and Eventspaces Question

From: Matthew Flatt (mflatt at cs.utah.edu)
Date: Tue Oct 28 21:12:41 EDT 2008

At Tue, 28 Oct 2008 19:08:07 -0600, "Doug Williams" wrote:
> The last two do exactly what I want.  The first two give "get-field:
> expected an object, got #f" when the Test button is clicked.  What is the
> difference?

The `parameterize' form introduces a binding only for the dynamic
extent of its body. So, in

  (lambda ()
    (parameterize ((current-frame (instantiate my-frame%
                                    ("Frame 1"))))
      (send (current-frame) show #t))))

the parameter binding is restored after the `show' method returns.

In contrast, in

  (lambda ()
    (let ((frame (instantiate my-frame%
                    ("Frame 3"))))
      (current-frame frame)
      (send (current-frame) show #t))))

the parameter's current binding is mutated, so the new value sticks
after the callback returns.


Posted on the users mailing list.