On 2014-01-26 22:20, Jakob Ovrum wrote:
C++ closures work similarly to D non-static nested structs: they carry copies or references to upvalues as hidden members of their type. In C++, this type is unnamed - there is no syntax for it, it can only be referred to with type inference (such as by wrapping it with std::function). In D, nested structs are named but the scope of the name is limited - once the struct instance leaves the function, it is no longer identifiable by name, which is the reason for their moniker "voldemort type".
That must be why the only way to refer to those nested struct types is by returning auto and using typeof on the variable that absorbs the value.
I was mostly wondering if the return values of static structs used inside the closure would be captured within that closure. I see it's only about local variables or other outer instances, so if I add a closure to a dynamic delegate array it should allow me to pick up a new pointer returned by the static struct.
I love your work on LuaD btw, I'm using it as the first step of runtime as a configuration file in a vibe.d cms/framework, and also as a vibe.d runtime page (I intend to pass over most of my convenience functions to luastate). It allows me to have configuration namespaces with comments, which is the most precious dependency of a library-based CMS. You can see an example of how I'm using it here: https://github.com/GlobecSys/w3Vibe/blob/master/examples/luadebugger/config.lua
Thanks!
