Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Initial support for callbacks #1726

Merged
merged 4 commits into from
Apr 24, 2023
Merged

Conversation

Smit-create
Copy link
Collaborator

@Smit-create Smit-create commented Apr 20, 2023

Fixes #1608

@certik
Copy link
Contributor

certik commented Apr 20, 2023

Something like that. I am refactoring the callbacks right now in LFortran. In LFortran, we either specify the function argument to be a Function symbol (instead of a Variable), or use a Variable, see lfortran/lfortran#1578 for a roadmap.

For now I think this PR is fine.

@Smit-create
Copy link
Collaborator Author

we either specify the function argument to be a Function symbol (instead of a Variable)

Yep, I have done the same thing in this PR. As in Fortran, we have an interface, for Python, whenever there's a function as a parameter, I create an empty callback function symbol in the scope of the parent function that works the same way as we do in the Fortran interface.

@Smit-create Smit-create requested a review from certik April 24, 2023 06:47
@Smit-create Smit-create marked this pull request as ready for review April 24, 2023 06:53
Copy link
Contributor

@certik certik left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that this is fine. Note that we have greatly improved the callbacks in LFortran just yesterday. After merging, do you think you could please sync LFortran/LPython on this?

Another issue: in LFortran we currently allow two ways to do callbacks:

  • Var points to Function directly
  • Var points to Variable, which points to FunctionType and Function

The second approach I think is more natural and versatile, so we should use it. That requires to sync LFortran's improvements here.

So to move forward, I suggest we merge this, then sync, and then rework it, maybe in few weeks after we harden the new approach in LFortran more.

@Smit-create
Copy link
Collaborator Author

Sure, would rework this once we sync libasr. Thanks!

@Smit-create Smit-create merged commit 91bc4aa into lcompilers:main Apr 24, 2023
@Smit-create Smit-create deleted the i-1608 branch April 24, 2023 13:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Supporting Callbacks in LPython
2 participants