You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Importing modules does not work inside the function #1317
Handle it in the frontend, so test_import.print_b() just becomes an ExternalSymbol to the correct print_b() and the information that it was called via test_import. will be lost.
Add test_import as a symbol into the SymbolTable.
The second approach is more general, it would allow to treat modules as symbols / variables. Not sure if we need it or not.
Oh yes. I am fixing working on this exact issue. I think we follow second approach right now. But for the case with function defined inside a module has the same name as the module then second approach will be messier because you will have to do name mangling. See mathfn for example, mathfn/sin.py is a module which has def sin defined inside it. So here first approach is an easy to follow option. However where this same name case is not present then second approach is easier.
I would work on this later, I think first we should implement more examples, such as making mathfn much more complex and see what else is missing. Then we can do this one in a more natural manner.
Activity
certik commentedon Nov 21, 2022
We have two options:
test_import.print_b()just becomes an ExternalSymbol to the correctprint_b()and the information that it was called viatest_import.will be lost.test_importas a symbol into the SymbolTable.The second approach is more general, it would allow to treat modules as symbols / variables. Not sure if we need it or not.
We need this in LFortran too to implement j3-fortran/fortran_proposals#1, so we should do a good design.
@czgdp1807 what is your opinion?
certik commentedon Nov 24, 2022
Regarding priorities, this is nice to have, but not critical, as we can simply import the symbols directly for now.
czgdp1807 commentedon Nov 24, 2022
Oh yes. I am
fixingworking on this exact issue. I think we follow second approach right now. But for the case with function defined inside a module has the same name as the module then second approach will be messier because you will have to do name mangling. Seemathfnfor example,mathfn/sin.pyis a module which hasdef sindefined inside it. So here first approach is an easy to follow option. However where this same name case is not present then second approach is easier.certik commentedon Nov 24, 2022
I would work on this later, I think first we should implement more examples, such as making mathfn much more complex and see what else is missing. Then we can do this one in a more natural manner.
Thirumalai-Shaktivel commentedon Dec 10, 2022
This issue is fixed (#1323), I think.