• Advertisement
Sign in to follow this  

Lambdas/Anon.Functions: Status, implementation

This topic is 764 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Heya. Finally made it to the forum :)

 

Recently I revived a concept for one of my projects and in reaction also brought back an old tool of mine. This has lead me to also looking into my concepts regarding AngelScript again.

 

I'd like to know:

 

- Are lambdas and anonymous functions implemented, to a production-ready level?

- How are they implemented?

 

I know that one can make a type definition that resembles a callback signature. But then? How is it used or passed, and how can a user pass a function to native APIs and call it - and vice versa?

 

Would be nice to know!

 

Kind regards,

Ingwie.

 

Share this post


Link to post
Share on other sites
Advertisement

Hi Ingwie. Welcome to the forum! :)

 

Yes. anonymous functions, a.k.a. lambdas, are now supported by AngelScript (since the last public release, 2.30.2).

 

Implementation wise, they are just ordinary script functions and can be passed to the application as a function pointer the same way. The function pointer is represented by the asIScriptFunction interface to the application. Using the function pointer it can be called using the script context normally.

 

The manual has an article that shows how to pass a function pointer to the application and then calling it.

 

Regards,

Andreas

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement