Re: Building STk on HP-UX

From: Berry Kercheval <>
Date: Mon, 13 Feb 1995 14:02:23 PST

I'm trying to build an application using STk and I ran into an unexpected
(though documented) problem.

Basically, the code bound to, say, a button widget that is to be executed when
the button is pressed, is evaluated in the global environment.

I want to be able to control the environment in which it is evaluated; I'd
like to be able to do, for instance

        (let* ((foo 1)
                (bar 2))
             (button "Frob" :command (lambda ()
                                             (frob foo bar))))

When I try it I get

        *** Read from string error:
        bad # syntax: "#"

because STk cannot deal with the "#[closure 0xfdo92c]" it gets back from Tk.

My question is, how hard would it be to support closures as widget actions?
If it's a GC problem (in that the lambda might get collected before it's
called, because Tk doesn't cooperate in GC) then why can't a thin layer of
glue code notice that this closure is being bound to that button, and hold
onto a live pointer so it won't be collected? It seems to me (though I
haven't dived into the code to see) that it would not be hard for the
interpreter evaluating the "string" of code from Tk to notice that it starts
"#[closure..." and do the right magic closure-invoking stuff. Yes? No?

Or perhaps the problem is more subtle (or more obvious) than I can see.


Berry Kercheval ::
Received on Mon Feb 13 1995 - 23:11:08 CET

This archive was generated by hypermail 2.3.0 : Mon Jul 21 2014 - 19:38:59 CEST