Skip to content
This repository has been archived by the owner on Sep 10, 2019. It is now read-only.

Use coroutines instead of xpcall #2

Open
LPGhatguy opened this issue Jun 13, 2018 · 1 comment
Open

Use coroutines instead of xpcall #2

LPGhatguy opened this issue Jun 13, 2018 · 1 comment
Labels
enhancement New feature or request

Comments

@LPGhatguy
Copy link
Owner

If this promise implementation wrapped each callback in a coroutine instead of using xpcall, then wrapping APIs that yield wouldn't require spawn. It would also help guard against cases where users yield intentionally or otherwise.

One thing to note is that we probably lose the ability to track errors after a yield has occurred. The current version bans yielding entirely, a previous version allowed it by virtue of using pcall, and this version would catch errors, but only if they occur before the first yield.

@LPGhatguy LPGhatguy added the enhancement New feature or request label Jun 17, 2018
@Validark
Copy link

You might want to take a look at my fork of the F3X Try library. The documentation is available here. I don't really like it though because it doesn't really have any specifications like Promises does, so what it should do is really just whatever I thought GigsD4X may have told me one night. However, it does have a few cool things that might give you good ideas for this library. It wraps all calls in a coroutine, and tracks the traceback along the way. If you do somehow arrive upon an error, it will "compile" the tracebacks into a single error message. It also doesn't create a new Attempt object internally, it reuses the same table object the entire time and simply changes the values accordingly.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants