Advertisement

allow ononamus function variable capturing?

Started by June 30, 2024 09:24 AM
2 comments, last by WitchLord 4 months, 3 weeks 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.

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

Advertisement

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

This topic is closed to new replies.

Advertisement