Provide explicit ways to prevent concurrency

I love what you’ve done to describe the situation. It’s a breath of fresh air to have this out in the open, and easy to follow.

If I read your description correctly, Skulpt will transpile the single statement

account1 -= amount_to_transfer

into a single, uninterruptable block of JavaScript code. Skulpt could provide a context-manager, e.g.,

with skulpt_interrupts_suspended() as transaction:
    # Transfer of funds; must be atomic!
    account1 -= amount_to_transfer
    account2 += amount_to_transfer

so that both go into the same uninterruptable block. The transpiler would have to recognize this as a special case, but it doesn’t need to introduce any new syntax.

Is there such a thing already? If so, does it play well with Anvil?

1 Like