-
Notifications
You must be signed in to change notification settings - Fork 73
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
opApply example isn't compliant with spec #372
base: master
Are you sure you want to change the base?
Conversation
The spec also says that the signature should be |
The In fact, it is crucial to do this for Why |
I've made a spec update: dlang/dlang.org#3699 |
Good to know. Am I right to assume that this is (mostly) only important for libraries? I always assumed the compiler or at least the optimizer could infer stuff like this, and annotating it is mostly for documentation and making sure that safe code doesn't rely on unsupported safeness of the code, leading to future breakage. |
The optimizer can easily inline an opApply call, and therefore the lambda. Most likely this happens regardless of whether the delegate is marked scope or not. But this is all after the frontend has decided whether the function is |
Aaaand, dmd just lets it happen. I guess this is a really old bug, which I actually commented on... https://issues.dlang.org/show_bug.cgi?id=16193 But I don't think it's fixed, I just tried this and got garbage. |
I would still recommend using scope, because at some point this could get "fixed". |
[The spec](https://dlang.org/spec/statement.html#foreach_over_struct_and_classes) states: >If the result is nonzero, apply must cease iterating and return that value.
Co-authored-by: Nick Treleaven <[email protected]>
Co-authored-by: Nick Treleaven <[email protected]>
Co-authored-by: Nick Treleaven <[email protected]>
Force pushed because I accidentally merged instead of rebased upstream |
c9bf6f2 The spec states:
The other commit add some other small improvements to make the example copy-pastable with minimal friction.