Skip to content

Conversation

@Menduist
Copy link
Contributor

Follow up on #251

raises: [Defect, CatchableError].} =
# we have to rely on inference here
{.pop.}
proc read*(future: Future | RaiseTrackingFuture ): auto =
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just make a separate read function for RTF? the auto return type here is unnecessarily wide as well, there's too many compromises for too little benefit

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed, we can avoid it here by making a specialized read for RTF

return retFuture

proc cancelAndWait*[T](fut: Future[T]): Future[void] =
proc cancelAndWait*[T](fut: Future[T]): RaiseTrackingFuture[void, (CancelledError,)] =
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
proc cancelAndWait*[T](fut: Future[T]): RaiseTrackingFuture[void, (CancelledError,)] =
proc cancelAndWait*[T](fut: Future[T]): Future[void] {.asyncraises:[(CancelledError,)] =

the rewrite to RTF should be macro-handled, no?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't have access to macros here (asyncmacro2 requires asyncfutures2)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe we should move this one elsewhere then - ie cancelAndWait is a composite "utility" operation much like allFutures etc - then we keep "primitives" in asyncfuture2 and maybe one fine day we can get rid of include altogether


return retFuture

proc wait*[T, E](fut: RaiseTrackingFuture[T, E], timeout = InfiniteDuration): auto =
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what's the return type here? in public functions, we ideally want to avoid auto both for documentation reasons and because it serves as a type inference guide for the compiler.

Copy link
Contributor Author

@Menduist Menduist Jul 23, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's RTF[T, E + CanceledError] (which I just realized is wrong, should be AsyncTimeoutError)

I don't know a better solution than auto for this kind of procedures (but I don't think it has an impact on type inference)

@Menduist Menduist mentioned this pull request Nov 8, 2022
Base automatically changed from raisetracking to master October 17, 2023 12:18
@arnetheduck
Copy link
Member

superseded by #454

@arnetheduck arnetheduck deleted the raisetrackingsupport branch October 25, 2023 07:57
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

Successfully merging this pull request may close these issues.

2 participants