Hi v8-users,
I'm trying to figure out how, from the C++ API, I can create a function
that effectively has some dynamically-captured state, as a closure might
have in pure Javascript. I need to generate many different instances of
the same function but with different captured values.
In Javascript, I might write:
var makeFoo(state) {
return function(arg) {
doSomething(state, arg);
}
}
I'm trying to figure out how to express this through the C++ bindings, but
it seems like it is not possible: FunctionTemplate's docs say it can only
create one instance of a function per context, and that instance lasts for
the lifetime of the context. So, creating many different FunctionTemplates
appears to be a bad idea. But v8::Arguments doesn't appear to contain any
inputs that aren't either provided by the caller or provided to the
FunctionTemplate, so I guess there's no place to put "captured" data.
Is this correct, or did I miss something?
I realize that I can design my C++ bindings in a procedural way (without
captures) and then wrap them in a Javascript wrapper to get the API I want,
which is probably what I'll end up doing, but wanted to verify that this is
really the only option.
Thanks,
-Kenton
--
--
v8-users mailing list
[email protected]
http://groups.google.com/group/v8-users
---
You received this message because you are subscribed to the Google Groups
"v8-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.