[racket] plot-frame does not wait at end of process

From: Laurent (laurent.orseau at gmail.com)
Date: Sun Mar 17 09:33:44 EDT 2013

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
<robby at 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.orseau at 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 <eli at 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
>>>
>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.racket-lang.org/users/archive/attachments/20130317/7e9fd938/attachment-0001.html>

Posted on the users mailing list.