Skip to content

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

Description

@davidbau

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?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions