-
-
Notifications
You must be signed in to change notification settings - Fork 608
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
Allow -preview=in only with extern(D|C++)
#12242
Conversation
|
Thanks for your pull request, @Geod24! Bugzilla referencesYour PR doesn't reference any Bugzilla issue. If your PR contains non-trivial changes, please reference a Bugzilla issue or create a manual changelog. Testing this PR locallyIf you don't have a local development environment setup, you can use Digger to test this PR: dub run digger -- build "master + dmd#12242" |
-preview=in can now be used with extern(C++), disabled for other non-D linkage-preview=in only with extern(D|C++)
b3d2cf7
to
2f6e0f6
Compare
In preparation for dlang/dmd#12242.
In preparation for dlang/dmd#12242.
In preparation for dlang/dmd#12242.
2f6e0f6
to
c62d09d
Compare
The argument is sent to another process, and can contain a pointer. Additionally, there is currently a PR in DMD to forbid using 'in' with extern(C) functions when '-preview=in' is provided (dlang/dmd#12242).
|
Maybe the |
The argument is sent to another process, and can contain a pointer. Additionally, there is currently a PR in DMD to forbid using 'in' with extern(C) functions when '-preview=in' is provided (dlang/dmd#12242).
|
Keep in mind that |
I think I'd prefer that for simplicity, otherwise the Edit: |
Not exactly meaningless, since the compiler will check
That was exactly my thought process. Maybe @ibuclaw can weight in ? |
That's actual the main problem.
P.S. I also think this would be nice. |
The same can be said of other attributes. IMO C++ |
In preparation for dlang/dmd#12242.
The argument is sent to another process, and can contain a pointer. Additionally, there is currently a PR in DMD to forbid using 'in' with extern(C) functions when '-preview=in' is provided (dlang/dmd#12242).
c62d09d
to
b43665e
Compare
In preparation for dlang/dmd#12242.
The argument is sent to another process, and can contain a pointer. Additionally, there is currently a PR in DMD to forbid using 'in' with extern(C) functions when '-preview=in' is provided (dlang/dmd#12242).
b43665e
to
5ca6608
Compare
|
I think it makes sense to be able to declare parameters to be And even if they are, I for one would like to tell the compiler that they're not escaped. |
In preparation for dlang/dmd#12242.
The argument is sent to another process, and can contain a pointer. Additionally, there is currently a PR in DMD to forbid using 'in' with extern(C) functions when '-preview=in' is provided (dlang/dmd#12242).
5ca6608
to
3e17144
Compare
122e09b
to
d1d1be2
Compare
3253bd3
to
cfab94c
Compare
|
I think this is finally passing the CI (!) |
| @@ -0,0 +1,11 @@ | |||
| `-preview=in` can now be used with `extern(C++)`, disabled for other non-D linkage | |||
|
|
|||
| The intent of `-preview=in` is to make `in` the go-to storage class for input parameters in D. | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this official vision?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Has Walter said those words exactly? Not that I recall. But he did put in, inout (now ref) and out in the language, so yeah I think that's as close as we'd get.
The intent of `-preview=in` is to make `in` the go-to storage class for input parameters in D. However it is D centric, as it is an enhanced version of `scope const ref`. As non-`extern(D)` functions usually are expected to match a specific ABI, using `in` is hardly a good idea. However, as C++, also have a "go to" storage class for input parameters (`const T&`), `in` can also be applied on `extern(C++)` function in order to bind to `const T&` parameters. This also allows to expose a closer API for a function than via `const ref`, as `in` will allow to bind rvalues to `const T&`, as in C++.
cfab94c
to
775b839
Compare
|
@dkorpel : Fixed |
|
I have nothing against this, would the likes of @atilaneves or @WalterBright wish to have another look? |
| case LINK.cpp: | ||
| fparam.storageClass |= STC.ref_; | ||
| break; | ||
| case LINK.default_, LINK.d: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What exactly does in mean for D linkage? Is it different than for C++?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This PR predates our decision to make in always mean ref. I'll correct it in the next PR.
|
Does the meaning of |
I hope not. |
|
Not after I disable the optimization, which is the next PR. |
@kinke @ibuclaw : Any opinion on this ? If this is too much, I can see two other course of action:
infor anything non-extern(D);inalways makescope constwithextern(C), neverref, disable for others;