-
-
Notifications
You must be signed in to change notification settings - Fork 419
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
Change refcap of JsonDoc to ref for better usability #2747
Conversation
I think it makes sense to fork off the json library stuff into an external package and work on it there where it is free from having to go through the RFC process. |
I thought this is a principle of least surprise thingy, so in this particular case i thought its ok to bypass the RFC process. |
"only have very little effect." I'm not sure this is a principal of least surprise and it is a breaking change. It merits a discussion. When I first read the PR, I thought this was the first of multiple changes, thus my, perhaps "outside the RFC" process comment. If its the only change then that can be ignored. Still, I think this needs to be discussed. This will quite possibly break folks code, its an API change, I don't see how its least surprise and its unclear to be what the usability gains that come from this are (and what usability will be lost). For example, with this change, I parse some Json in a TCPConnectionNotify. How do I send that to another actor? |
Let me illustrate the usability improvement: The current state is, if i want to parse json and access the data structure, i am doomed: use "json"
actor Main
new create(env: Env) =>
try
let doc = JsonDoc
doc.parse("""{"array": [1, "str", true]}""")
let obj = doc.data as JsonObject
end Surprisingly this doesn't compile, but fails with:
As JsonDoc is returned from the constructor as let doc: JsonDoc = JsonDoc Here is is automatically "downgraded" to The main advantage of having The change in this PR:
let sendable_doc = recover iso JsonDoc.>parse(json_string) end |
ok, im ok with this @mfelsche. Your explanation on the sync call convinced me. |
Adding "DO NOT MERGE" that can be removed after 0.22.6 is released |
Can you add release notes to this @mfelsche before its merged? |
Release notes draftThe This is all gone now, use "json"
actor Main
new create(env: Env) =>
try
let doc = JsonDoc
doc.parse("""{"array": [1, "str", true]}""")
let obj = doc.data as JsonObject
end |
JsonType has not been sendable anyways as JsonObject and JsonArray have been of refcap ref in JsonType, so this only changes JsonDoc to be non-sendable, which should only have very little effect. My first iteration was to make JsonDoc, JsonObject and JsonArray iso but this turned out to be cumbersome to use (especially when traversing into nested structures). The other possibility would be to make all elements of JsonType val but this also turns out to be a little limiting when constructing a JSON structure, so i went with the least invasive way for now.
JsonType has not been sendable anyways as JsonObject and JsonArray have been of refcap ref in JsonType,
so this only changes JsonDoc to be non-sendable, which should only have very little effect.
My first iteration was to make JsonDoc, JsonObject and JsonArray iso but this turned out to be cumbersome to use (especially when traversing into nested structures).
The other possibility would be to make all elements of JsonType val but this also turns out to be a little limiting when constructing a JSON structure, so i went with
the least invasive way for now.
Also added some package docs.