Hi All I am new to Racket and I have found a situation where I'm not certain why Racket works the way it does. Unfortunately I am not sure of the vocabulary so I will describe the situation with some code:
; A button made this way works as I would expect, it waits for 30 minutes and then shows a message-box and plays a sound. (new button% [parent long-break-panel] [label "Long Break"] ; Callback procedure for a button click: [callback (lambda (button event) (send long-break-msg set-label "Long break timer started") (general-timer 30 long-break-callback))]) ; A button made this way immediately shows the message box and plays the sound. (new button% [parent long-break-panel] [label "Long Break"] ; Callback procedure for a button click: [callback (lambda (button event) (send long-break-msg set-label "Long break timer started") (general-timer 30 (general-callback long-break-msg "Not on long break" "30 Minutes have passed, back to work.")))]) ; A button made this way also immediately shows the message box and plays the sound. Why is it different when the function name is surrounded by parentheses? (new button% [parent long-break-panel] [label "Long Break"] ; Callback procedure for a button click: [callback (lambda (button event) (send long-break-msg set-label "Long break timer started") (general-timer 30 (long-break-callback)))]) ; The documentation for buttons say they require a callback. I interpreted this to mean a function that will execute when the button is clicked. (define general-callback (lambda (msg-name msg-text message-box-text) (time-expired-sound) (send msg-name set-label msg-text) (message-box "Timer expired" message-box-text frame))) ; Why does wrapping the function so that it takes no parameters change how it gets executed? (define long-break-callback (lambda () (general-callback long-break-msg "Not on long break" "30 Minutes have passed, back to work."))) Is anyone able to explain why I am getting these different behaviors from these buttons? Regards Philip -- 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/3a6effce-915e-42c8-aff7-56fc23524e4c%40googlegroups.com.