[racket] Questions about the Canvas
Thank you very much. That clears everything right up.
-Hillary
On Wed, Jun 13, 2012 at 4:11 PM, Stephen Bloch <bloch at adelphi.edu> wrote:
>
> On Jun 13, 2012, at 3:16 PM, Hillary Ryan wrote:
>
> > Why does this work?
> > (define canvas (new canvas% [parent window] [paint-callback (lambda
> (canvas dc) (draw canvas dc))]))
> >
> > But this doesn't
> > (define canvas (new canvas% [parent window] [paint-callback (draw
> canvas dc)]))
> >
> > It seems that in both cases the paint-callback is being set to a 2-arity
> procedure.
>
> No, "(draw canvas dc)" is the RESULT of a 2-arity procedure. "draw" (no
> parentheses, no arguments) would be a 2-arity procedure, equivalent to
> "(lambda (canvas dc) (draw canvas dc))".
>
> > However, in the second case the window doesn't update unless draw is
> called from REPL.
>
> Yes, that's because you're only calling draw once, at the time you define
> canvas.
>
>
>
> Stephen Bloch
> sbloch at adelphi.edu
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20120613/8b613178/attachment.html>