Skip to content
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

Feature/prop #3924

Open
wants to merge 9 commits into
base: series/3.x
Choose a base branch
from
Open

Conversation

massimosiani
Copy link

Addresses #3313.

@djspiewak
Copy link
Member

Thank you for looking at this! An interesting question for us to answer though is what we want to do with Native and JavaScript. This is a bit different from Env, which works on all three platforms (with the exception of in-browser JS).

@armanbilge
Copy link
Member

Native and JavaScript

They both support System properties. It's basically just a global mutable map.

@durban
Copy link
Contributor

durban commented Jan 4, 2024

A question: the getAndSet, modify, and similar methods look like the ones on Ref. However, here they are not atomic, right? So having them could be somewhat misleading. (While having only get and set would make it clear, that there is no atomicity for modification.)

@massimosiani
Copy link
Author

I would agree. TBH, I wondered whether we should try and make them atomic, but that's probably not something you'd expect by system props.

@durban
Copy link
Contributor

durban commented Jan 5, 2024

I don't think we can make them atomic. Or do you know a way?

@massimosiani
Copy link
Author

Right, not sure how could be made atomic. Citing Arman, it's basically just a global mutable map.
I'll remove getAndSet and getAndUpdate but I think that update is still useful if we make clear that there are no guarantees about concurrent modifications. It's a handy wrapper for a get followed by set. I also like modify as a wrapper but would like to hear other opinions.

@armanbilge
Copy link
Member

I think that update is still useful if we make clear that there are no guarantees about concurrent modifications

Unfortunately I think it's still confusing. Anyway, I expect 99% of usecases to just be reading system properties. APIs that require setting/updating system properties seem really dicey 🙄

@durban
Copy link
Contributor

durban commented Jan 6, 2024

I'd just go with get, set and remove. If that's the functionality offered by the platform, and we can't provide atomicity, its best simply to wrap those.

@armanbilge
Copy link
Member

armanbilge commented Jan 6, 2024

Similar to Env, we can also add something to list/iterate the keys/entries.

*/
def unset(key: String): F[Unit]

def entries: F[Properties]
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not sure I like returning a mutable object here. (I think we usually try to avoid that?)

Copy link
Member

Choose a reason for hiding this comment

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

For Env we decided to return an Iterable[(String, String)], but that was because of case-sensitivity issues which I don't think apply here. So probably makes most sense to return an immutable Map[String, String].

@armanbilge armanbilge added this to the v3.6.0 milestone May 20, 2024
@armanbilge armanbilge closed this May 20, 2024
@armanbilge armanbilge reopened this May 20, 2024
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.

None yet

4 participants