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

Drop the changes to variables in async functions #20

Open
acomagu opened this issue Nov 1, 2019 · 2 comments
Open

Drop the changes to variables in async functions #20

acomagu opened this issue Nov 1, 2019 · 2 comments

Comments

@acomagu
Copy link
Owner

acomagu commented Nov 1, 2019

e.g.

set i 0
function fish_prompt
    set i (math $i + 1)
    echo $i >
end

set -g async_prompt_inherit_variables status i

The above don't increment.

@acomagu
Copy link
Owner Author

acomagu commented Nov 1, 2019

If anyone wants this fixed, mention or add reaction here.

@Anton-Latukha
Copy link

Anton-Latukha commented Mar 7, 2020

I love what you did.

As I understand - the values do not change in the global fish scope.

I think the exported variables to be immutable, it is a lot more classical approach, safe and most practical design choice. This way it is much easier to keep the main thread & async running very robustly and for everyone to be happy. When you add a backward sharing of values - it would have an effect of complicating all work, reports, cases further.

Everything is working (I have my complex setup & exported to async a bit of side-processes) now.

I think the default should be that scope of global values should stay immutable for async threads.

I would say the obvious things that you already know.

If global scope is immutable - async processes can import & shadow variables over with local copies, mutate local values for themself and do what they want - they are containerized, those changes not be exported into global fish scope. This approach allows most things needed by people & simplifies async greatly, makes it robust, easy to run and works for all main cases.

And if a person requires - have a switch that allows mutating the global scope values. And you would see how many people need that and what are the cases & how much those cases valid. And you would always have a possibility to state that mutable mode can be dangerous & are you providing support for it & are contributions welcome.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants