Comment by pjmlp

Comment by pjmlp a day ago

7 replies

You are expecting them to actually check the value, there is nothing preemptive.

Another approach is special messages over a side channel.

deepsun a day ago

So instead of a context you need to pass a a channel. Same problem.

  • pjmlp a day ago

    Not necessarily, that is one of the reasons OOP exists.

    Have a struct representing the set of associated activities, owning the channel.

    • ozgrakkurt a day ago

      soo, a context?

      • ncruces a day ago

        You can take that view, yes.

        But if you store your context in a struct (which is not the recommend “best practice” – but which you can do) it's no longer a function coloring issue.

        I do that in on of my libraries and I feel that it's the right call (for that library).

      • pjmlp a day ago

        Nope, because I didn't mention it was to be passed around as a compulsory parameter, rather have your logic organised across structs with methods, hide most details behind interfaces.