Live++ Forums
Lambda functions - Printable Version

+- Live++ Forums (https://liveplusplus.tech/forums)
+-- Forum: Live++ (https://liveplusplus.tech/forums/forum-1.html)
+--- Forum: Technical issues (https://liveplusplus.tech/forums/forum-6.html)
+--- Thread: Lambda functions (/thread-13.html)



Lambda functions - bstone - 10-26-2020

Hello!

Wanted to ask if lambda functions are not supported by Live++ as that's not currently mentioned in the known limitations section of the documentation. But I'm observing changes to code in lambda functions not updating at all. Is this by design or can be fixed eventually?


RE: Lambda functions - Stefan Reinalter - 10-26-2020

Hi,

Lambda functions are supported by Live++ and you should see changes applied to them.
Are you sure the function containing the lambda is re-entered and patched?


RE: Lambda functions - bstone - 10-27-2020

Hi!

Thanks for the prompt reply!

Now that you said they should be working, I created a simple test, and they indeed worked all right there. My issue was that the lambda functions were part of a class method that was called during the static instance initialization. I guess the problem here is that Live++ doesn't re-initialize static variables, unlike Hot Reload. I'm dealing with the Unreal Engine framework, where I noticed that hot-reloading worked with those lambdas but Live++ did not. Hence my original conclusion and the question.

Thanks again for clearing that up!


RE: Lambda functions - Stefan Reinalter - 10-27-2020

(10-27-2020, 09:46 AM)bstone Wrote: My issue was that the lambda functions were part of a class method that was called during the static instance initialization. I guess the problem here is that Live++ doesn't re-initialize static variables, unlike Hot Reload. I'm dealing with the Unreal Engine framework, where I noticed that hot-reloading worked with those lambdas but Live++ did not.

I find it quite interesting that UE HotReload re-initializes static (and global) variables.
In my opinion, that is waiting for disaster to happen, especially when constructors of those variables have side effects, such as modifying global state, initializing other systems, etc. If those side effects are not completely reversed in the destructor, re-initializing those variables and running the constructor again can have severe effects.

Live++ does not attempt to re-initialize static or global variables. What has already been constructed, stays constructed. The only exception to this is const/read-only data, e.g. a global array of const data.
However, new static or global variables introduced in a hot-reload patch will be properly initialized/constructed by Live++.


RE: Lambda functions - bstone - 10-27-2020

Yeah, that's questionable behavior but I reckon it's just the way hot-reloading works, i.e. they inject a new DLL into the process so there's no real way to avoid initializing old static variables. Could be also why it's not very stable after all.


RE: Lambda functions - Stefan Reinalter - 10-27-2020

(10-27-2020, 04:32 PM)bstone Wrote: Yeah, that's questionable behavior but I reckon it's just the way hot-reloading works, i.e. they inject a new DLL into the process so there's no real way to avoid initializing old static variables. Could be also why it's not very stable after all.

Live++ also injects DLLs into the process, but takes extra care that constructors of existing symbols are not called again.
Totally agree regarding stability!