[Vala] The state of closures
- From: "Sam Liddicott" <sam liddicott com>
- To: Vala ML <vala-list gnome org>
- Subject: [Vala] The state of closures
- Date: Thu, 28 Apr 2011 15:58:32 +0100
My last recollection of vala closures accessing variables of the
enclosing function is that they would need what are normally stack-local
variables to be allocated on the heap and be made accessible to the
closure my means of a private pointer to the struct of the local variables.
I don't know if this is still the plan, but i draw attention to section
4.4 of http://gcc.gnu.org/onlinedocs/gcc-2.95.3/gcc_4.html
entitled "nested functions"
I suppose that this might not be new information to Vala developers.
It refers to a document Usenix88-lexic.pdf which may be found here
http://web.pdx.edu/~hegbloom/download/Usenix88-lexic.pdf
What is interesting is the use of trampolines so that the "address" of
the local function may be taken and passed about (provided that the
containing function has not exited). The trampoline permits the correct
local variables to be accessed by the address, even if the function is
re-entrant or recursive.
I suppose that the "address" is taken as an automatic variable on the
stack and so is freed when the containing function exits.
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.
Sam
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]