[plt-scheme] exception in local variable access from augmented method

From: Matthew Flatt (mflatt at cs.utah.edu)
Date: Sat Dec 6 11:28:14 EST 2008

At Fri, 5 Dec 2008 00:07:51 -0500 (EST), Dimitris Vyzovitis wrote:
> I am trying to mutate a local variable from an augmented method, but all I 
> get is a horrible exception. Here is an example:
> (define Frame%
>    (class frame%
>      (define foo 0)
>      (define (can-close?)
>        (printf "~a~n" foo)
>        (set! foo (add1 foo))
>        #t)
>      (augment can-close?)
>      (super-new)))
> (define xx (new Frame% (label "Foo") (width 300) (height 300)))
> (send xx show #t)
> (yield 'wait)
> <click>
> 0
> procedure application: expected procedure, given: 0; arguments were: 0 1

I haven't been able to get that error when running the code above,
either under Mac OS X or X11. I put "#lang scheme/gui" at the beginning
of the code and tried running in both DrScheme (Module language) and
MrEd. I'm assuming that "<click>" means clicking to close the frame.

Is there more to the program or a different way I should run it?


Posted on the users mailing list.