acomagu / fish-async-prompt

Make your prompt asynchronous to improve the reactivity.
MIT License
390 stars 22 forks source link

Drop the changes to variables in async functions #20

Open acomagu opened 4 years ago

acomagu commented 4 years ago

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 commented 4 years ago

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

Anton-Latukha commented 4 years ago

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.