nevalang / neva

🌊 Dataflow programming language with static types and implicit parallelism. Compiles to native code and Go
https://nevalang.org
MIT License
94 stars 7 forks source link

context.Context #668

Open emil14 opened 5 months ago

emil14 commented 5 months ago

In Go we pass ctx context.Context argument explicitly. We solve 2 problems this way

  1. Cancelation
  2. Passing values without "props drilling"

Here we only talk about first problem - cancelation. How to cancel (terminate) execution before it naturally ends? E.g. by timeout.

On Go Way

I see a downside of Go's solution. Extra ctx argument is a boilerplate and once it appears somewhere it can spreads throwout the call-stack.

Are there better solutions? What other languages offer?

emil14 commented 5 months ago

Odin

https://odin-lang.org/docs/faq/#context-system

TODO research

emil14 commented 5 months ago

Kotlin

https://kotlinlang.org/docs/cancellation-and-timeouts.html#cancelling-coroutine-execution

TODO

emil14 commented 6 days ago

Implicit Approach

Every component implicitly has :ctx context.Context inport. User is not allowed to add inport with such name explicitly. ...