Hi gfb Thank you for replying to my question.
Your reply has saved me from writing unnecessary boiler plate code for my click events. I see the difference between mentioning a function and evaluating it now. What I ended up going for looks like this: ; Make a button in the frame (new button% [parent work-panel] [label "Work"] ; Callback procedure for a button click: [callback (lambda (button event) (send work-msg set-label "Work timer started") (make-timer 25 (lambda () (timer-callback work-msg "Not working" "25 Minutes have passed, take a break."))))]) Regards Philip On Tuesday, 12 May 2020 20:37:32 UTC+2, gfb wrote: > > The difference is whether you are evaluating an expression, versus > putting it inside a function to be evaluated when the function is called. > > (require racket/gui) > > ; Call message-box, get an immediate effect ... > (message-box "What do you think?" "hi, would you like a tomato" #f > '(yes-no)) > ; The result ('yes or 'no) is printed in the repl/Interactions. > > ; Create a function/procedure, that takes no arguments, and its body calls > message-box ... > (lambda () (message-box "Greeting" "hi, would you like a tomatillo" #f > '(yes-no))) > ; That which prints as #<procedure> since it's a function, and we didn't > call it. > > ; To call a function we put parentheses around it ... > ((lambda () (message-box "Greeting" "hi, would you like a pomodoro" #f > '(yes-no))) > ) > ; That evaluated the body. > > ; Name a function ... > (define greeter (lambda () (message-box "Greeting" "hi, would you like a > green tomato" #f '(yes-no)))) > ; That didn't call it, and neither do ... > greeter > greeter > ; Those just mention the function, which prints as #<procedure>. > ; Call it to evaluate the body .. > (greeter) > > By the way, your examples that don't wait 30 minutes actually do, > and if you wait 30 minutes they will try to call the callback, which > is not a function but the 'ok result from the message-box. > > Try setting the timer to something shorter, and then wait after > you click the immediate message box, then when the timer > goes off there will be an error something like ... > application: not a procedure; > expected a procedure that can be applied to arguments > given: 'ok > arguments...: [none] > > -- You received this message because you are subscribed to the Google Groups "Racket Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to racket-users+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/racket-users/d4276f08-2501-46df-bad0-ab43867b75d2%40googlegroups.com.