[racket] Nesting evt handlers

From: Tobias Hammer (tobias.hammer at dlr.de)
Date: Thu Mar 28 11:28:38 EDT 2013

Thanks, that's clear now.

Another question regarding events: Why is it forbidden to put a handle-evt  
inside another handle- or wrap-evt?
I couldn't come up with a situation where this could cause trouble.  
Especially as it is allowed to nest handle-evts if i put a guard-evt or a  
struct with prop:evt in between.

Tobias



On Thu, 28 Mar 2013 16:17:00 +0100, Matthew Flatt <mflatt at cs.utah.edu>  
wrote:

> Sometimes, `sync' picks the first evt that it is given before even
> trying the second evt enough to call the evt-generating function. That
> is, `sync' looks far enough to see all arguments are `evt?', but
> calling the evt-generator part of a guard evt is part of the attempt to
> choose the specific guard evt, and that action doesn't happen if some
> other evt succeeds first.
>
> I'll work on the docs to clarify.
>
> Yes, `proc' should be `generator'. But, `generator' also should be
> changed, because "generator" now means something specific and
> different.
>
> At Thu, 28 Mar 2013 16:08:09 +0100, Tobias Hammer wrote:
>> Hi,
>>
>> i am trying to understand how nack-guard-evt works. Therefore i created
>> the appended test program. Sometimes it stops with the error message and
>> sometimes it prints the three values. It is clear to me what the error
>> means and why it is raised.
>> What i am not understanding is, why the nack generator is not run every
>> time sync is called. I would have expected from the docs that it is run  
>> on
>> every sync.
>> Can someone clarify why my assumptions are wrong and how nack-guard-evt  
>> is
>> expected to behave?
>>
>> Related question: The docs for the function talk abound 'proc', should  
>> it
>> be 'generator'?
>>
>> Tobias
>>
>>
>>
>> ;; -----------------------------
>>
>> #lang racket
>>
>> (define nack #f)
>>
>> (sync (handle-evt
>>         always-evt
>>         (lambda (_) 'ALWAYS))
>>        (nack-guard-evt
>>         (lambda (e)
>>           (set! nack e)
>>           never-evt)))
>>
>> nack
>> (printf "~a\n" (sync/timeout 0. nack))
>>
>> > 'ALWAYS
>> #f
>> . . sync/timeout: contract violation
>>    expected: evt?
>>    given: #f
>>    argument position: 2nd
>>    other arguments...:
>>     0.0
>>
>> OR
>>
>> > 'ALWAYS
>> #<evt>
>> #<void>
>>
>>
>>
>> --
>> ---------------------------------------------------------
>> Tobias Hammer
>> DLR / Robotics and Mechatronics Center (RMC)
>> Muenchner Str. 20, D-82234 Wessling
>> Tel.: 08153/28-1487
>> Mail: tobias.hammer at dlr.de
>> ____________________
>>   Racket Users list:
>>   http://lists.racket-lang.org/users


-- 
---------------------------------------------------------
Tobias Hammer
DLR / Robotics and Mechatronics Center (RMC)
Muenchner Str. 20, D-82234 Wessling
Tel.: 08153/28-1487
Mail: tobias.hammer at dlr.de

Posted on the users mailing list.