google / starlark-go

Starlark in Go: the Starlark configuration language, implemented in Go
BSD 3-Clause "New" or "Revised" License
2.26k stars 204 forks source link

Add quit() or exit() functions #478

Closed Nextraind closed 1 year ago

Nextraind commented 1 year ago

Just like Python itself

adonovan commented 1 year ago

Python's quit and exit functions, which are equivalent in behavior, are oddly not documented as built-ins even though in Python3 they are both regular built-ins that terminate the current thread.

In Starlark we have the fail function, which similarly generates an error in the current thread. (Perhaps it should have been named exit or quit.) The REPL doesn't terminate when it encounters the error from fail; perhaps it should.

Please re-open this issue if fail is not suitable for your needs.

Nextraind commented 1 year ago

I want to quit the rest part of the script, and no throw any exceptions. fail() works, but it throws error.

Nextraind commented 1 year ago

@adonovan Btw, I can't reopen it, since I'm not a colabrator of this repo. Got no such button ---

image