In his second version (see below), Matthew was basically encapsulating what you have written inside (yield ...). Would you mind to explain what differences that makes? I've read the docs but I'm still confused about `yield'.
>> >> > #lang at-exp racket >> >> > (require plot >> >> > racket/gui/base) >> >> > (plot-new-window? #t) >> >> > (yield >> >> > (thread >> >> > (lambda () >> >> > (let loop () >> >> > (let ((dummy (read))) >> >> > (if (and (number? dummy) (zero? dummy)) >> >> > (void) >> >> > (begin >> >> > ;; queue a callback instead of `plot' directly: >> >> > (queue-callback >> >> > (lambda () >> >> > (plot (function (λ(x) (* x x)) -2 2)))) >> >> > (loop)))))))) Thanks, Laurent On Sun, Mar 17, 2013 at 2:13 PM, Robby Findler <ro...@eecs.northwestern.edu>wrote: > That way has the property that each plot window has its own thread of > execution, which is probably not necessary (I don't know if plot windows > communicate or if that matters), but if it were me, I'd probably just make > one extra thread, not N, and I'd put the reading into the extra thread not > the GUI, like the below. > > #lang racket/gui > (require plot) > (plot-new-window? #t) > (define (do-one) > (define dummy (read)) > (cond > [(and (number? dummy) (zero? dummy)) > #f] > [else > (queue-callback > (λ () > (plot (function (λ (x) (* x x)) -2 2)))) > #t])) > > (when (do-one) > (void > (thread > (λ () > (let loop () > (when (do-one) > (loop))))))) > > > > > On Sun, Mar 17, 2013 at 4:42 AM, Laurent <laurent.ors...@gmail.com> wrote: > >> So, does this means that Deren's program from >> http://lists.racket-lang.org/users/archive/2012-April/051490.html >> would then look like that: >> >> #lang racket >> (require plot) >> (plot-new-window? #t) >> (let loop () >> (let ((dummy (read))) >> (if (and (number? dummy) (zero? dummy)) >> (void) >> (begin >> (parameterize ([current-eventspace (make-eventspace)]) >> (plot (function (λ(x) (* x x)) -2 2))) >> (loop))))) >> >> ? >> >> Laurent >> >> >> On Sun, Mar 17, 2013 at 7:15 AM, Eli Barzilay <e...@barzilay.org> wrote: >> >>> On Thursday, Robby Findler wrote: >>> > Also: I don't think that you need a parameter for this default. the >>> > current-eventspace parameter would already do this job. >>> >>> IOW, Robby wants no keyword or parameter, just the default behavior, >>> and if there's a problem with that then people would deal with it like >>> with any other gui code. FWIW, I'm on that side too. >>> >>> -- >>> ((lambda (x) (x x)) (lambda (x) (x x))) Eli Barzilay: >>> http://barzilay.org/ Maze is Life! >>> ____________________ >>> Racket Users list: >>> http://lists.racket-lang.org/users >>> >> >> >
____________________ Racket Users list: http://lists.racket-lang.org/users