diff --git a/compiler/res/version.txt b/compiler/res/version.txt index ab9dda59f..2e0e38c63 100644 --- a/compiler/res/version.txt +++ b/compiler/res/version.txt @@ -1 +1 @@ -1.9-dev +1.9 diff --git a/docs/source/programming.rst b/docs/source/programming.rst index 5cd52bc03..781f85b30 100644 --- a/docs/source/programming.rst +++ b/docs/source/programming.rst @@ -361,8 +361,11 @@ You can also create loops by using the ``goto`` statement, but this should usual Loop variables that are declared inline are scoped in the loop body so they're not accessible at all after the loop finishes. -Conditional Execution (IF) --------------------------- +Conditional Execution +--------------------- + +if statements +^^^^^^^^^^^^^ Conditional execution means that the flow of execution changes based on certiain conditions, rather than having fixed gotos or subroutine calls:: @@ -413,11 +416,15 @@ So ``if_cc goto target`` will directly translate into the single CPU instruction Maybe in the future this will be a separate nested scope, but for now, that is only possible when defining a subroutine. -When - statement (jumptable) -^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +when statement (jumptable) +^^^^^^^^^^^^^^^^^^^^^^^^^^ .. attention:: - TODO: docs for this this must still be written + TODO: docs for this this must still be written. + TODO: the code generator for this is not yet working. + + Use a ``when`` statement if you have a set of choices that each should result in a certain + action. It's more readable (and results in faster code) than using a lot of if / else statements. Assignments diff --git a/docs/source/syntaxreference.rst b/docs/source/syntaxreference.rst index 58f946677..d18a1e2ef 100644 --- a/docs/source/syntaxreference.rst +++ b/docs/source/syntaxreference.rst @@ -610,7 +610,28 @@ The XX corresponds to one of the eigth branching instructions so the possibiliti ``if_cs``, ``if_cc``, ``if_eq``, ``if_ne``, ``if_pl``, ``if_mi``, ``if_vs`` and ``if_vc``. It can also be one of the four aliases that are easier to read: ``if_z``, ``if_nz``, ``if_pos`` and ``if_neg``. -**When - statement (jumptable)** -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +when statement (jumptable) +^^^^^^^^^^^^^^^^^^^^^^^^^^ .. attention:: - TODO: docs for this this must still be written + TODO: docs for this this must still be written. + TODO: the code generator for this is not yet working. + + The condition value can only be an integer datatype. + The choice values must be constant integer values. + + code example:: + + when 4+A+Y { + 10 -> { + c64scr.print("ten") + } + 5 -> c64scr.print("five") + 30 -> c64scr.print("thirty") + 99 -> c64scr.print("nn") + 55 -> { + ; will be optimized away + } + else -> { + c64scr.print("!??!\n") + } + }