Re: [Vala] The state of closures




On 28/04/11 16:44, Luca Bruno wrote:
On Thu, Apr 28, 2011 at 04:38:43PM +0100, Sam Liddicott wrote:
On 28/04/11 16:08, Luca Bruno wrote:
On Thu, Apr 28, 2011 at 03:58:32PM +0100, Sam Liddicott wrote:
This feature may be less useful for vala if it does stack-tear-down
for interruptable functions, but perhaps more suited if it uses
co-routines with different stacks so that the stack is switched and
not torn-down when an interruptable function is interrupted.
Yes that's the problem, with vala you may pass the closure to another
function and exit from the current scope, while with gcc nested function
the stack is lost once you exit the outer function.
And it's hard to control this or know when it is happening by accident.

I wonder if it is worth considering libpcl or other co-routine
libraries - it would take away the need for a lot of effort to get
fuller closure support.

I've also been thinking of ways to detect when vala closures go
stale - one way is for the data pointer to be indirected via a heap
allocated pointer. This could be set to null by the outer function
when it exits, and so any use after this point can be detected - as
when the wrapper trampoline function is executed it will detect that
the data pointer points to NULL instead of pointing to the actual
data pointer.
I don't get what's the problem with actual vala closures that you need to
find an alternative
yes.. it's been a few years since I piped up.

Part of the problem is (or was) with interruptable functions which tear-down the stack and thus invalidate the closure for interruptable functions.

Another is that last time I checked closures still could not access local variables in the enclosing function.

I was suggesting that if GCC closure support were used and co-routines for interruptable functions that then closures could access local variables of the enclosing functions quite well. Otherwise

This stemmed from a time when I was trying to use vala to write samba 4 modules where the closure support (with access to variables of the enclosing function) would have been very useful if it could survive the tear-down of the stack (which libpcl co-routines provide).

Sam




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]