/
ColdCore-3.0a9.02/
ColdCore-3.0a9.02/src/
new object $help_coldc_cond_switch: $help_coldc_cond_stmts;

var $has_name name = ['prop, "switch", "switch"];
var $help_node body = <$ctext_frob, [[<$format, ["p", [], [], 'do_p]>, "The ", <$format, ["i", [], ["switch statement"], 'do_i]>, " is used to compare one value against a series of other values. The switch statement is the most complicated statement in ColdC, and does vary from it's counterpart in C, so rather than using abstract explanations we will start with an example:", <$format, ["p", [], [], 'do_p]>, <$format, ["dfn", [], [<$format, ["quote", [], ["switch (val) {\n    case 0:\n        echo(\"The value is zero.\");\n    case 1 .. 10:\n        echo(\"The value is between one and ten inclusive.\");\n    case 11 .. a:\n        echo(\"The value is between eleven and a inclusive.\");\n    case \"foo\", \"bar\"..\"baz\":\n        echo(\"The value is \\\"foo\\\" or between \\\"bar\\\" and \\\"baz\\\"\");\n    case a .. b, c .. d, 42:\n        count = count + 1;\n        echo(\"The value is in the counted area.\");\n    case ~perm:\n        echo(\"Permission denied while getting the value.\");\n    default:\n        echo(\"Did not recognize value.\");\n}"], 'do_quote]>], 'do_dfn]>, <$format, ["p", [], [], 'do_p]>, "This example illustrates all of the capabilities of the switch statement. The expression given by ", <$format, ["tt", [], ["val"], 'do_tt]>, " in the example is the ", <$format, ["i", [], ["controlling expression"], 'do_i]>, ", and is compared against each of the cases inside the switch body until a match is found. Each ", <$format, ["tt", [], ["case"], 'do_tt]>, " has a value or list of values to compare against. The values can be of any type, and need not be constant expressions. Ranges are specified using two dots (", <$format, ["tt", [], [".."], 'do_tt]>, ") to separate the lower and upper bounds. The keyword ", <$format, ["tt", [], ["default"], 'do_tt]>, " specifies an action to perform if no cases were matched by the controlling expression. ", <$format, ["np", [], [], 'do_np]>, "Here is a more formal description of the syntax of the switch statement:", <$format, ["p", [], [], 'do_p]>, <$format, ["dfn", [], [<$format, ["tt", [], ["switch (", <$format, ["i", [], ["controlling-expression"], 'do_i]>, ") { ", <$format, ["dfn", [["ind", "4"]], ["case ", <$format, ["i", [], ["expr-or-range"], 'do_i]>, ", ", <$format, ["i", [], ["expr-or-range"], 'do_i]>, ", ", <$format, ["i", [], [".."], 'do_i]>, ": ", <$format, ["dfn", [["ind", "4"]], ["statement"], 'do_dfn]>, "case ", <$format, ["i", [], ["expr-or-range"], 'do_i]>, ", ", <$format, ["i", [], ["expr-or-range"], 'do_i]>, ", ", <$format, ["i", [], [".."], 'do_i]>, ": ", <$format, ["dfn", [["ind", "4"]], ["statement"], 'do_dfn]>, <$format, ["i", [], [".."], 'do_i]>, <$format, ["br", [], [], 'do_br]>, "default: ", <$format, ["dfn", [["ind", "4"], ["nobound", 1]], [<$format, ["i", [], ["default-statement"], 'do_i]>], 'do_dfn]>], 'do_dfn]>, "}"], 'do_tt]>], 'do_dfn]>, <$format, ["p", [], [], 'do_p]>, "When executing a switch statement, the interpreter scans through the list of cases and compares the ", <$format, ["i", [], ["controlling-expression"], 'do_i]>, " against each of the cases, evaluating the case from left to right until there is a match. When using a range, the lower and upper bounds must be of the same type and must be either integers or strings. If they are not the error ", <$format, ["tt", [], ["~type"], 'do_tt]>, " is thrown. When the interpreter finds a match, it will execute the statement for that case. The interpreter will not continue checking cases after a match. ", <$format, ["np", [], [], 'do_np]>, "If the interpreter does not find a match, it will execute instead execute the ", <$format, ["i", [], ["default-statement"], 'do_i]>, ". A default statement does not need to be defined. If a default is not defined nothing in the switch is executed. ", <$format, ["np", [], [], 'do_np]>, <$format, ["tt", [], ["C"], 'do_tt]>, " programmers should note that switch statements in ColdC differ from switch statements in ", <$format, ["tt", [], ["C"], 'do_tt]>, " in several respects. Because case values do not have to be constants, they may conflict, in which case the first match will take precedence. Also, there is no fall-through in ColdC switch statements; only the statements corresponding to the matching case will be executed. Because there is no fall-through, the ", <$format, ["tt", [], ["break"], 'do_tt]>, " statement does not apply to switch statements. Finally, the default case must be placed last in the list of cases if it is given."], #[['this, $help_coldc_cond_switch]]]>;
var $help_node index = $help_index_driver;
var $help_node links = #[];
var $help_node nolist = 0;
var $root created_on = 854395484;
var $root flags = ['variables, 'methods, 'code, 'core];
var $root inited = 1;
var $root managed = [$help_coldc_cond_switch];
var $root manager = $help_coldc_cond_switch;