diff options
author | Araq <rumpf_a@web.de> | 2014-10-02 10:08:41 +0200 |
---|---|---|
committer | Araq <rumpf_a@web.de> | 2014-10-02 10:08:41 +0200 |
commit | c99ec1654452eede8b374eb85cb05b2e759be23f (patch) | |
tree | cf6362bf57bd1129654a89d05a305a99dcac00d2 /doc | |
parent | 2011805829089d631951411c4a7cc7ab33653712 (diff) | |
download | Nim-c99ec1654452eede8b374eb85cb05b2e759be23f.tar.gz |
deprecated string case statements without 'else'
Diffstat (limited to 'doc')
-rw-r--r-- | doc/manual/stmts.txt | 10 | ||||
-rw-r--r-- | doc/tut1.txt | 2 |
2 files changed, 5 insertions, 7 deletions
diff --git a/doc/manual/stmts.txt b/doc/manual/stmts.txt index b706101e1..1307ff917 100644 --- a/doc/manual/stmts.txt +++ b/doc/manual/stmts.txt @@ -262,13 +262,11 @@ given *slicelist* the ``else`` part is executed. If there is no ``else`` part and not all possible values that ``expr`` can hold occur in a ``slicelist``, a static error occurs. This holds only for expressions of ordinal types. "All possible values" of ``expr`` are determined by ``expr``'s -type. +type. To suppress the static error an ``else`` part with an +empty ``discard`` statement should be used. -If the expression is not of an ordinal type, and no ``else`` part is -given, control passes after the ``case`` statement. - -To suppress the static error in the ordinal case an ``else`` part with an -empty ``discard`` statement can be used. +For non ordinal types it is not possible to list every possible value and so +these always require an ``else`` part. As a special semantic extension, an expression in an ``of`` branch of a case statement may evaluate to a set or array constructor; the set or array is then diff --git a/doc/tut1.txt b/doc/tut1.txt index 2a836190c..950f758f1 100644 --- a/doc/tut1.txt +++ b/doc/tut1.txt @@ -312,7 +312,7 @@ the compiler that for every other value nothing should be done: The empty `discard statement`_ is a *do nothing* statement. The compiler knows that a case statement with an else part cannot fail and thus the error disappears. Note that it is impossible to cover all possible string values: -that is why there is no such check for string cases. +that is why string cases always need an ``else`` branch. In general the case statement is used for subrange types or enumerations where it is of great help that the compiler checks that you covered any possible |