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

Merge Function/Subroutine into Function #866

Closed
certik opened this issue Aug 1, 2022 · 1 comment
Closed

Merge Function/Subroutine into Function #866

certik opened this issue Aug 1, 2022 · 1 comment

Comments

@certik
Copy link
Contributor

certik commented Aug 1, 2022

Even in ASR the two are slowly diverging, and they should not. I would do something like this:

--- a/src/libasr/ASR.asdl
+++ b/src/libasr/ASR.asdl
@@ -84,12 +84,9 @@ symbol
         stmt* body)
     | Module(symbol_table symtab, identifier name, identifier* dependencies,
         bool loaded_from_mod, bool intrinsic)
-    | Subroutine(symbol_table symtab, identifier name, expr* args, stmt* body,
-        abi abi, access access, deftype deftype, string? bindc_name, bool pure,
-        bool module)
     | Function(symbol_table symtab, identifier name, expr* args, stmt* body,
-        expr return_var, abi abi, access access, deftype deftype, bool elemental,
-        string? bindc_name)
+        expr? return_var, abi abi, access access, deftype deftype,
+        string? bindc_name, bool pure, bool elemental, string? bindc_name)
     | GenericProcedure(symbol_table parent_symtab, identifier name,
         symbol* procs, access access)
     | CustomOperator(symbol_table parent_symtab, identifier name,

If return_var is null, it's a subroutine, otherwise it's a function.

We have written a lot of code that is either exactly identical for both subroutine/function or almost identical. This change would greatly simplify the whole usage.

@certik
Copy link
Contributor Author

certik commented Aug 5, 2022

Done!! LFortran and LPython now use just Function.

@certik certik closed this as completed Aug 5, 2022
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

No branches or pull requests

1 participant