Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Every turtle function should have an optional "done" callback last argument. #24

Open
davidbau opened this issue Feb 2, 2014 · 0 comments

Comments

@davidbau
Copy link
Member

davidbau commented Feb 2, 2014

Every turtle function should have an optional "done" callback last argument.

For example, "lt 90, -> write 'finished'" should wait until the left turn is finished before writing the message.

Here is why: when learning "await done defer()" with iced coffeescript, the question sometimes comes up, "why can't I wrap await and defer around any function?" By implementing callbacks uniformly around turtle methods that do queuing, the answer can be, "you can do that for any function that can queue an async process."

await lt 90, defer()

This would affect the signatures of a lot of methods: fd, bk, lt, rt, slide, movexy, moveto, jump, jumpto, turnto, home, pen, fill, dot, pause, st, ht, pu, pd, pe, pf, play, speed, wear, reload, twist, scale... However "read" methods that are synchronous such as getxy would not get the optional argument.

The change would look something like this:
https://github.com/PencilCode/jquery-turtle/compare/continuationstyle

Opinions?

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

No branches or pull requests

1 participant