Return Values

Handling widgets means not only sending messages but also receiving data. That’s not a problem as the following lines show:

(tk/bind tk)

=> "<Destroy>"

The same as the appropriate Tcl/Tk command—reasonable. But now:

(tk/bind tk '<Destroy>)

=> "callToScm g12"

Less reasonable. We are not interested in how lambda expressions are invoked but instead the lambda terms themselves.

Set the global variable *tk-returns-proper-list* and try again:

(set! *tk-returns-proper-list* #t)
(tk/bind tk '<Destroy>)

=> (#<procedure>)

When *tk-returns-proper-list* is set to #t, the widget's return values are converted to Scheme data, here the lambda expression with event-generated argument fields (in this example, none).

So, why not always set it to #t? Because in some situations this would be really fatal, e. g. when reading text from text widgets or entries.


© Author | Home | Sitemap