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

Should inout or out be allowed for extern or export functions? #16329

Open
mppf opened this issue Sep 3, 2020 · 4 comments
Open

Should inout or out be allowed for extern or export functions? #16329

mppf opened this issue Sep 3, 2020 · 4 comments

Comments

@mppf
Copy link
Member

mppf commented Sep 3, 2020

Over time, we have been migrating the handling of in, out, and inout intents to the call site rather than within the called function. At the same time, I noticed recently that we have some tests using extern proc with inout arguments. I'm pretty sure that these are better written using ref intent but the question here is whether such things should be allowed?

Should an extern proc be allowed to use inout or out intent? These are not implemented in C. However they are now handled at the call site, and so the Chapel compiler could copy in such cases.

Should a generated C wrapper for export proc be allowed to use inout or out intent? These are not implemented in C and C code calling such a function can't automatically handle these details at the call site.

Anyway I am currently of a mind that we should disallow these cases for now and allow them again over time when we are confident that they are reasonable features and work correctly.

mppf added a commit to mppf/chapel that referenced this issue Sep 3, 2020
I created issue chapel-lang#16329 to ask if we should allow inout/out
intents for extern/export.
@bradcray
Copy link
Member

bradcray commented Sep 3, 2020

I'm pretty open to not supporting intents for extern procs that C doesn't support since extern is all about describing C routines for Chapel's benefit.

Since export is more about making Chapel available to other languages, I'm more in favor of supporting all Chapel intents that we can manage to implement; say, via wrappers. For example, given:

export proc foo(in x: int, inout y: int) { ... }

I'd imagine we'd have the callable-from Chapel version of foo named foo_chpl in the object file, say. Can we simulate the intents that C doesn't support in the exported-to-C/whatever foo function by having it handle any callee-specific behaviors? (presumably for someone calling the routine from C, they would see in the generated header that the formal arguments required an int* or whatever?).

To me, if we can pull this off, it seems the most consistent/productive for what I think of export as meaning.

@mppf
Copy link
Member Author

mppf commented Sep 3, 2020

@bradcray - I think it is worth a try to do as you describe for export - but in the mean time should we disallow these intents until we sort it out?

@bradcray
Copy link
Member

bradcray commented Sep 3, 2020

If they don't work today, that would be fine with me.

@mppf
Copy link
Member Author

mppf commented Sep 3, 2020

PR #16334 will explore adding this error for now.

mppf added a commit to mppf/chapel that referenced this issue Sep 3, 2020
I created issue chapel-lang#16329 to ask if we should allow inout/out
intents for extern/export.
mppf added a commit to mppf/chapel that referenced this issue Sep 8, 2020
I created issue chapel-lang#16329 to ask if we should allow inout/out
intents for extern/export.
mppf added a commit that referenced this issue Sep 22, 2020
Add error for extern/export with out/inout intent

For issue #16329.

- [x] full local testing

Reviewed by @lydia-duncan - thanks!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants