Skip to content

Provides better compatibility for primitive %string_safe_set#772

Closed
bobzhang wants to merge 4 commits intoocaml:4.04from
rescript-lang:4.04
Closed

Provides better compatibility for primitive %string_safe_set#772
bobzhang wants to merge 4 commits intoocaml:4.04from
rescript-lang:4.04

Conversation

@bobzhang
Copy link
Member

@bobzhang bobzhang commented Aug 19, 2016

Now %string_safe_set is treated the same as %bytes_safe_set, and %string_safe_set is only used to set bytes instead of string
This is a follow-up of GRP #596

@alainfrisch alainfrisch added this to the 4.04 milestone Aug 23, 2016
Changes Outdated
- GPR#772 %string_safe_set is treated the same as %bytes_safe_set,
and %string_safe_set is only used to set bytes instead of string, it is
strongly recommended to use `%bytes_safe_set`, `%string_safe_set`
maybe removed in the future.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

may be

@alainfrisch
Copy link
Contributor

alainfrisch commented Aug 23, 2016

I'm in favor of not breaking existing code, but I believe that only the change in translcore.ml is required to achieve that. (And bootstrapping does not seem required either.)

@damiendoligez
Copy link
Member

I agree with Alain.

@gasche
Copy link
Member

gasche commented Aug 23, 2016

To clarify: the compatibility breakage I've seen in the wild comes from changing the primitive name of the string-related externals, which are advertised in the interfaces of some libraries that basically include String. So it would be best if the primitives of all functions in the String modules remained %string_... (this means that the present PR has to change them back to what they were before #596), but the primitives of the Bytes module (or bytes_* functions) can be the new %bytes_* primitive -- in theory that may break compatibility as well as recent code could have re-exported this Bytes module with the %string names, but this is recently modified code that will be easy to update, not old code that hasn't been touched and kept working for years.

@bobzhang
Copy link
Member Author

I don't have opinions here, my current PR will not break any existing code, should we use "%bytes_safe_set" somewhere, like Bytes.ml?

@gasche
Copy link
Member

gasche commented Aug 24, 2016

Yes, I think String* modules should use %string_* and Bytes* modules should use %bytes_*. Similarly, bytes_set could use %bytes, as Alain mentions in his code comment.

I think that once this PR lands in 4.04 it would be nice to have a second beta to fish out the remaining issues -- there are already a few fixes in the branch that it would be nice to have users test. I updated Batteries with the post-#596 state (changing all %string_ to %bytes_), and I'm waiting for the resolution of this PR to update again (reverting some of the changes) and make a 4.04-compatible release -- I suspect that extlib may be in the same position, cc: @ygrek.

@alainfrisch
Copy link
Contributor

which are advertised in the interfaces of some libraries that basically include String

Thanks, I see. This could also be addressed by having the compiler normalize %string_safe_set to %bytes_safe_set early enough so as not to break the inclusion check, but I'm also ok with the current solution.

Any opposition to merging this PR in its current state?

@gasche
Copy link
Member

gasche commented Aug 25, 2016

Code-wise, I like the current state -- I haven't checked yet that it does restore buildability of affected packages but we can always adjust after the fact. Do we need the bootstrap part?

@bobzhang
Copy link
Member Author

we need do at least one bootstrap pass, doing once is the same as doing twice. (I did it twice just in case)

@mshinwell
Copy link
Contributor

I am in favour of this patch, having recently encountered this breakage...

@gasche
Copy link
Member

gasche commented Aug 26, 2016

@damiendoligez can we get this into 4.04? Thinking about this, I think that a reviewed version of the -cclib PR should also be part of another beta release.

@damiendoligez
Copy link
Member

@gasche let me test this PR. It seems to me that String.create and String.unsafe_set will also cause problems in their current state.

@damiendoligez
Copy link
Member

completed and removed the bootstrap, then merged into 4.04 (commit 9b0da03)

Now the wget, rml, and flowcaml packages compile correctly.

@gasche
Copy link
Member

gasche commented Aug 30, 2016

(Batteries hasn't had a release with the previous primitive states so there is no compatibility issues with rolling back the changes. If users took the habit of following trunk more closely, some of them would similarly have to roll back on changes we cancel for compatibility reasons.)

stedolan pushed a commit to stedolan/ocaml that referenced this pull request Sep 21, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants