🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

allow ononamus function variable capturing?

Started by
2 comments, last by WitchLord 2 days, 17 hours ago

having the ability to capture variables from the scope of ononamus functions will be extremely great, right now, ononamus function feel quite restricting and inflexible

as an example, assume I have an ononamus function sent to a function that expects one, where it will call it after an action is proformmed, however, inside, I might want to call a class member that is important, as an example, a network handler, or maybe just a class method that notifies the user, right now I cannot do something like this, and while yes I could make the function handles take arguments to the class I'm using, however that will eventually result in extremely difficult code to maintain where I'll be forced to put everything in one class, which I might as well use global variables lol.

apologies if my message is confusing/explanation isn't clear, if that is the case please tell me so and I will clarify.

thanks.

Advertisement

also, I'm not sure if this went to angelscript forum or not, intended it for there, new to the site so might have, put it in the wrong place? If so I have no idea how to fix that

Hi emperor,

What you're referring to are called ‘closure’. It's on my to-do list and has been for a long time, but it is not something trivial to implement. Especially when taking safety into consideration, as the script engine must ensure that the closure cannot access local variables that may no longer be available if the original function that created the closure has already returned.

Regards,
Andreas

AngelCode.com - game development and more - Reference DB - game developer references
AngelScript - free scripting library - BMFont - free bitmap font generator - Tower - free puzzle game

Advertisement