Добавил:
Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
C-sharp language specification.2004.pdf
Скачиваний:
14
Добавлен:
23.08.2013
Размер:
2.55 Mб
Скачать

Chapter 15 Statements

1Because the switch statement does not permit a switch section to “fall through” to the next switch

2section, it is a compile-time error for the end point of the statement list of a switch section to be

3reachable. If this error occurs, it is typically an indication that a break statement is missing.

4It is a compile-time error for the end point of the block of a function member that computes a value to be

5reachable. If this error occurs, it typically is an indication that a return statement is missing.

615.2 Blocks

7A block permits multiple statements to be written in contexts where a single statement is allowed.

8block:

9{ statement-listopt }

10A block consists of an optional statement-list (§15.2.1), enclosed in braces. If the statement list is omitted,

11the block is said to be empty.

12A block can contain declaration statements (§15.5). The scope of a local variable or constant declared in a

13block is the block.

14Within a block, the meaning of a name used in an expression or declarator context shall always be the same

15(§14.5.2.1).

16A block is executed as follows:

17If the block is empty, control is transferred to the end point of the block.

18If the block is not empty, control is transferred to the statement list. When and if control reaches the end

19point of the statement list, control is transferred to the end point of the block.

20The statement list of a block is reachable if the block itself is reachable.

21The end point of a block is reachable if the block is empty or if the end point of the statement list is

22reachable.

2315.2.1 Statement lists

24A statement list consists of one or more statements written in sequence. Statement lists occur in blocks

25(§15.2) and in switch-blocks (§15.7.2).

26statement-list:

27

28

statement

statement-list statement

29A statement list is executed by transferring control to the first statement. When and if control reaches the end

30point of a statement, control is transferred to the next statement. When and if control reaches the end point of

31the last statement, control is transferred to the end point of the statement list.

32A statement in a statement list is reachable if at least one of the following is true:

33The statement is the first statement and the statement list itself is reachable.

34The end point of the preceding statement is reachable.

35The statement is a labeled statement and the label is referenced by a reachable goto statement.

36The end point of a statement list is reachable if the end point of the last statement in the list is reachable.

3715.3 The empty statement

38An empty-statement does nothing.

39empty-statement:

40

;

217

Соседние файлы в предмете Электротехника