diff --git a/README.md b/README.md index 3f47ac0..64e906c 100644 --- a/README.md +++ b/README.md @@ -9,7 +9,8 @@ Python v2 is a programming language that lets you work quickly and integrate systems more effectively — same energy as the original snake, without the paper cuts. No indentation errors. Real closures. F-strings that just work. -A ternary that reads left to right. And it runs **right in your browser**. +Structured errors you can actually recover from. A ternary that reads left to +right. And it runs **right in your browser**. ```python # hello.pyv2 @@ -45,6 +46,7 @@ The product is: 384 | `nonlocal` scavenger hunts | closures just work | | `"n=" + str(n)` | `"n=" + n` | | `x if ok else y` (backwards) | `ok ? x : y` | +| exception classes for routine app errors | `catch error` gives a useful map; `finally` always runs | | `assert` is a keyword with moods | `assert(cond, msg)` is a function | | trailing commas *sometimes* | trailing commas & multi-line everything | | one runtime | two parity-tested runtimes — CLI **and** browser | @@ -206,8 +208,8 @@ The short version: $ python3 -m unittest discover -s tests -t . ``` -**108 tests pass:** 63 language tests, 9 PyHope engine tests, 14 production-app/build tests, -13 workspace/Launcher tests, 8 arcade/Playground site tests, plus a parity harness that runs 25 programs (including error paths) through both the +**112 tests pass:** 67 language tests, 9 PyHope engine tests, 14 production-app/build tests, +13 workspace/Launcher tests, 8 arcade/Playground site tests, plus a parity harness that runs 28 programs (including error paths) through both the Python and JavaScript runtimes and demands byte-identical output. ## 📦 Repo layout diff --git a/docs.html b/docs.html index b6e434f..03c1dba 100644 --- a/docs.html +++ b/docs.html @@ -9,6 +9,7 @@ +
@@ -69,7 +70,7 @@

Documentation

-
+
@@ -508,10 +509,29 @@

Statements

whilewhile running: step() end forfor item in [1, 2, 3]: print(item) end range loopfor i in range(1, 10, 2): print(i) end + recovertry: risky() catch error: print(error.kind) finally: cleanup() end + raiseraise {kind: "ConfigError", message: "port required"} jumpreturn, break, continue +

Structured error recovery

+

Runtime errors are catchable values. A named catch receives a map with + kind, message, line, and trace. + The optional finally block always runs, including during + return, break, and continue.

+
try:
+    result = 100 / divisor
+catch error:
+    print(error.kind + ":", error.message)
+    result = 0
+finally:
+    print("calculation complete")
+end
+

raise "message" creates a UserError. Raise a map with string + kind and message fields to create a named application error. + Syntax errors are detected before execution and are not catchable.

+

Builtins

@@ -519,6 +539,8 @@

Builtins

+ + @@ -596,7 +618,7 @@

Community

GitHubIssuesNews - Events + Events - +
FunctionDescription
print(...)Print values, space-separated
len(x)Length of string / list / map / range
range(stop) · range(a, b, step)Integer range
sum · enumerate · zipIterable aggregation and pairing
all · anyTruth tests across an iterable
str int float bool reprConversions
abs floor ceil round sqrt powMath
min · maxOver arguments or one list
Examplesexamples/hello, fib, fizzbuzz, terminal_raycast
VS Code extensioneditors/vscode/Syntax highlighting + snippets
Dev container.devcontainer/Ready environment for VS Code / Codespaces
Teststests/108 tests: language + app/EXE builder + parity + PyHope + workspace + Playground + arcade
Teststests/112 tests: language + app/EXE builder + parity + PyHope + workspace + Playground + arcade
@@ -370,7 +371,7 @@

Community

GitHub Issues News - Events + Events