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

Make exit() a builtin #1416

Closed
wants to merge 1 commit into from
Closed

Make exit() a builtin #1416

wants to merge 1 commit into from

Commits on Aug 6, 2023

  1. Make exit() a builtin

    Instead of env.exit() we now have exit(cap: WorldCap, exit_code: int) as
    a builtin function. The primary benefit is that functions are executed
    synchronously unlike actor methods which are async. Thus, env.exit()
    typically required using `await async env.exit(0)` whereas as a function
    it is called as a synchronous procedure, so `exit(env.cap, 0)` is
    enough.
    
    Having to add `await async` meant users could do the wrong thing. With
    exit() as a function, there is no ambiguity. The user cannot do anything
    wrong! Also, this is shorter and more to the point. Less confusing to
    new usres. The only weird thing now is the capability argument...
    
    I think we should have a new ExitCap capability, but I want to keep down
    the amount of clutter right now, in particular for something as
    important as 'exit'. Beginners will see it early and it's scary when it
    look all too scary. Accepting WorldCap means we can do `exit(env.cap,
    0)` otherwise it would probably be like `exit(ExitCap(env.cap), 0)` and
    it's just extra bits complicating things. I think we should have ExitCap
    but as exit() is so common that it should be acceptable to use WorldCap
    directly. For the few programs where one actually wants to delegate a
    restricted ExitCap capability, that should be possible to by having an
    ExitCap but it would require exit() to accept a union, either an ExitCap
    or WorldCap. We don't have unions yet, so it will have to wait.
    plajjan committed Aug 6, 2023
    Configuration menu
    Copy the full SHA
    3db3169 View commit details
    Browse the repository at this point in the history