[plt-scheme] Reference to an identifier before its definition
As I try to start the following program, I receive the message
reference to an identifier before its definition: handle-ok
I see that handle-ok is defined after its use, and if I move the definition before its use,
(e.g at the top of the program), it works.
However, in the definition of handle-ok, I CAN refer to msg, even if it is defined after its use.
So the question is :
Are forward references to definitions allowed ?
Regards
Maurizio
---- This doesn't works --------------
#lang scheme/gui
(define frame (new frame% [label "Example"]))
(define msg (new message% [parent frame]
[label "No events so far..."]))
(new button% [parent frame]
[label "Click Me"]
(callback handle-ok)) ; <--- ERROR
(define (handle-ok button event)
(send msg set-label "Button click"))
(send frame show #t)
---- This works --------------
#lang scheme/gui
(define (handle-ok button event)
(send msg set-label "Button click")) ; <---- REFERENCE TO MSG IS OK !!!!!!
(define frame (new frame% [label "Example"]))
(define msg (new message% [parent frame]
[label "No events so far..."]))
(new button% [parent frame]
[label "Click Me"]
(callback handle-ok))
(send frame show #t)
-------------- next part --------------
-----------------------------------------------------------------------------
Il presente messaggio, corredato dei relativi allegati, contiene informazioni da considerarsi strettamente riservate ed ? destinato esclusivamente al destinatario sopra indicato, il quale ? l'unico autorizzato ad usarlo, copiarlo e, sotto la propria responsabilit?, diffonderlo. Chiunque ricevesse questo messaggio per errore o comunque lo leggesse senza esserne legittimato ? avvertito che trattenerlo, copiarlo, divulgarlo, distribuirlo a persone diverse dal destinatario ? severamente proibito, ed ? pregato di rinviarlo immediatamente al mittente distruggendone l'originale.
This message, together with its annex(es), contains information to be deemed strictly confidential and is destined only to the addressee(s) identified above who only may use, copy and, under his/their responsibility, further disseminate it. If anyone received this message by mistake or reads it without entitlement is forewarned that keeping, copying, disseminating or distributing this message to persons other than the addressee(s) is strictly forbidden and is asked to transmit it immediately to the sender and to erase the original message received.