-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Clarify which runtime interactions are allowed in custom ops #12819
Conversation
Raising an exception definitely counts as accessing the runtime. You are raising a real issue with the documentation but the fix you propose might be too specific. I refer to the discussion at #12594. As I feared, the change in documentation went overboard. Can cc @gasche |
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.
Answering to my own questions above, caml_deserialize_error
does not just raise an exception but it also cleans-up intern state. So it appears to be an exception to the rule of not accessing the runtime, that does not mean that deserialize can access the runtime. In the end, the addition you propose seems pertinent.
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.
Approved on @gadmm's behalf.
"Accessing the runtime system" is so vague as to be meaningless. Custom deserializers can use the little API described in https://v2.ocaml.org/releases/5.1/htmlman/intfc.html#ss:c-custom-serialization , through which they "access the runtime system" in some manner, but a controlled one. I'm not sure the proposed change makes sense; why mention |
It still lifts the misunderstanding about not being able to raise during deserialize. You can replace the mention of caml_deserialize_error by a link to ss:c-custom-serialization, whose advantage is that caml_deserialize_error is documented in more detail. |
Agreed. Maybe something along the line of the following would work better (should be checked by someone with better knowledge of the actual restrictions than me): Note: the
The mention of Edit: I will also note that the rest of the custom deserializer API is mentioned a couple lines above, in the documentation for the "deserialize" function (albeit with no link to subsection 9.4), but that mention makes it seem like this API is only meant for reading data:
|
The rewording sounds good to me, thanks! I agree with the need to put more cross-refs. |
af1c059
to
33c1cde
Compare
caml_deserialize_error
in manual33c1cde
to
369033d
Compare
Updated the PR with the proposed rewording, and took the opportunity to add a link to subsection 9.4 in the "deserialize" and "serialize" docs. Also changed the PR title to better reflect the new changes. |
@bclement-ocp should I add the "no-changes-required" label, or do you want to put a Changes entry? |
I forgot the Changes entry, added. |
Changes
Outdated
@@ -373,6 +373,10 @@ Working version | |||
(Olivier Nicole, review by Miod Vallat, Sebastien Hinderer, Fabrice Buoro, | |||
Gabriel Scherer and KC Sivaramakrishnan) | |||
|
|||
- #12819: Clarify which runtime interactions are allowed in custom ops | |||
(Basile Clément, review by Guillaume Munch-Maccagnoni, Gabriel Scherer and |
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.
I did not review this PR ("on behalf of" secretly means "I didn't read this in details").
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.
But now you did 🤔
I added the people involved in the discussion without giving it any more thought — removed your name.
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 sounds good to me, and is an improvement, by mention of the special functions for serialize/deserialize.
Unfortunately we did not gain in precision. It now says "when in doubt, err on the side of caution". This is unavoidable because the vagueness of the documentation goes deeper and is also a vagueness in specification of the runtime.
As a side-note, people who want to see improvements about the situation are welcome to support (or even contribute to) ongoing efforts which aim to give a precise meaning to “accessing the OCaml runtime”.
0587883
to
850c330
Compare
Clarify that, while the custom operations must not access the OCaml runtime, the
caml_deserialize_error
function can be used to signal an error during deserialization.