status-im / nim-chronos

Chronos - An efficient library for asynchronous programming
https://status-im.github.io/nim-chronos/docs/chronos
Apache License 2.0
353 stars 51 forks source link

introduce `asyncraises` to core future utilities #454

Closed arnetheduck closed 11 months ago

arnetheduck commented 11 months ago

Similar to the introduction of raises into a codebase, asyncraises needs to be introduced gradually across all functionality before deriving benefit.

This is a first introduction along with utilities to manage raises lists and transform them at compile time.

Several scenarios ensue:

Both of the above cases are currently handled by a macro, but depending on the situation lead to code organisation issues around return types and pragma limitations - in particular, to keep asyncraises backwards-compatibility, some code needs to exist in two versions which somewhat complicates the implementation.

cheatfate commented 11 months ago

I thinik you missed or here and it become as complex as noCancel. Because in case of or it should create union of exceptions of Future1 and Future2. Personally i do not like this primitive because it has weird design, for some reason it returns only errors, but not values. From my point of view it should not return errors too, but i think there some code around which depends on this ugly implementation. Same problem has and implementation, but at least it was marked as deprecated and i think we should at least start removing this deprecated functions, so we can introduce more proper primitives on its place.

arnetheduck commented 11 months ago

I thinik you missed or here and it become as complex as

Well, I intentionally left it out for now because it's not used that much - because of the default CatchableError raises, it's not wrong, just sub-optimal. That said, it is indeed an odd implementation so I don't really want to touch it in this PR - maybe it should be deprecated and maybe not, but I don't think it's worth updating to asyncraises right now.

start removing

Removing is not a problem generally but if another version is added with the same name, it becomes difficult to maintain compatibility or at least compile-time discoverability of what needs to be updated.