Заглавная страница Избранные статьи Случайная статья Познавательные статьи Новые добавления Обратная связь FAQ Написать работу КАТЕГОРИИ: АрхеологияБиология Генетика География Информатика История Логика Маркетинг Математика Менеджмент Механика Педагогика Религия Социология Технологии Физика Философия Финансы Химия Экология ТОП 10 на сайте Приготовление дезинфицирующих растворов различной концентрацииТехника нижней прямой подачи мяча. Франко-прусская война (причины и последствия) Организация работы процедурного кабинета Смысловое и механическое запоминание, их место и роль в усвоении знаний Коммуникативные барьеры и пути их преодоления Обработка изделий медицинского назначения многократного применения Образцы текста публицистического стиля Четыре типа изменения баланса Задачи с ответами для Всероссийской олимпиады по праву Мы поможем в написании ваших работ! ЗНАЕТЕ ЛИ ВЫ?
Влияние общества на человека
Приготовление дезинфицирующих растворов различной концентрации Практические работы по географии для 6 класса Организация работы процедурного кабинета Изменения в неживой природе осенью Уборка процедурного кабинета Сольфеджио. Все правила по сольфеджио Балочные системы. Определение реакций опор и моментов защемления |
Simple assignment expressionsСодержание книги
Поиск на нашем сайте
For an expression expr of the form w = expr-rhs: · The definite assignment state of v before expr-rhs is the same as the definite assignment state of v before expr. · If w is the same variable as v, then the definite assignment state of v after expr is definitely assigned. Otherwise, the definite assignment state of v after expr is the same as the definite assignment state of v after expr-rhs. 5.3.3.24 && expressions For an expression expr of the form expr-first && expr-second: · The definite assignment state of v before expr-first is the same as the definite assignment state of v before expr. · The definite assignment state of v before expr-second is definitely assigned if the state of v after expr-first is either definitely assigned or “definitely assigned after true expression”. Otherwise, it is not definitely assigned. · The definite assignment state of v after expr is determined by: o If expr-first is a constant expression with the value false, then the definite assignment state of v after expr is the same as the definite assignment state of v after expr-first. o Otherwise, if the state of v after expr-first is definitely assigned, then the state of v after expr is definitely assigned. o Otherwise, if the state of v after expr-second is definitely assigned, and the state of v after expr-first is “definitely assigned after false expression”, then the state of v after expr is definitely assigned. o Otherwise, if the state of v after expr-second is definitely assigned or “definitely assigned after true expression”, then the state of v after expr is “definitely assigned after true expression”. o Otherwise, if the state of v after expr-first is “definitely assigned after false expression”, and the state of v after expr-second is “definitely assigned after false expression”, then the state of v after expr is “definitely assigned after false expression”. o Otherwise, the state of v after expr is not definitely assigned. In the example class A the variable i is considered definitely assigned in one of the embedded statements of an if statement but not in the other. In the if statement in method F, the variable i is definitely assigned in the first embedded statement because execution of the expression (i = y) always precedes execution of this embedded statement. In contrast, the variable i is not definitely assigned in the second embedded statement, since x >= 0 might have tested false, resulting in the variable i being unassigned. 5.3.3.25 || expressions For an expression expr of the form expr-first || expr-second: · The definite assignment state of v before expr-first is the same as the definite assignment state of v before expr. · The definite assignment state of v before expr-second is definitely assigned if the state of v after expr-first is either definitely assigned or “definitely assigned after false expression”. Otherwise, it is not definitely assigned. · The definite assignment statement of v after expr is determined by: o If expr-first is a constant expression with the value true, then the definite assignment state of v after expr is the same as the definite assignment state of v after expr-first. o Otherwise, if the state of v after expr-first is definitely assigned, then the state of v after expr is definitely assigned. o Otherwise, if the state of v after expr-second is definitely assigned, and the state of v after expr-first is “definitely assigned after true expression”, then the state of v after expr is definitely assigned. o Otherwise, if the state of v after expr-second is definitely assigned or “definitely assigned after false expression”, then the state of v after expr is “definitely assigned after false expression”. o Otherwise, if the state of v after expr-first is “definitely assigned after true expression”, and the state of v after expr-second is “definitely assigned after true expression”, then the state of v after expr is “definitely assigned after true expression”. o Otherwise, the state of v after expr is not definitely assigned. In the example class A the variable i is considered definitely assigned in one of the embedded statements of an if statement but not in the other. In the if statement in method G, the variable i is definitely assigned in the second embedded statement because execution of the expression (i = y) always precedes execution of this embedded statement. In contrast, the variable i is not definitely assigned in the first embedded statement, since x >= 0 might have tested true, resulting in the variable i being unassigned. 5.3.3.26! expressions For an expression expr of the form! expr-operand: · The definite assignment state of v before expr-operand is the same as the definite assignment state of v before expr. · The definite assignment state of v after expr is determined by: o If the state of v after expr-operand is definitely assigned, then the state of v after expr is definitely assigned. o If the state of v after expr-operand is not definitely assigned, then the state of v after expr is not definitely assigned. o If the state of v after expr-operand is “definitely assigned after false expression”, then the state of v after expr is “definitely assigned after true expression”. o If the state of v after expr-operand is “definitely assigned after true expression”, then the state of v after expr is “definitely assigned after false expression”. Expressions For an expression expr of the form expr-first?? expr-second: · The definite assignment state of v before expr-first is the same as the definite assignment state of v before expr. · The definite assignment state of v before expr-second is the same as the definite assignment state of v after expr-first. · The definite assignment statement of v after expr is determined by: o If expr-first is a constant expression (§7.19) with value null, then the the state of v after expr is the same as the state of v after expr-second. · Otherwise, the state of v after expr is the same as the definite assignment state of v after expr-first. Expressions For an expression expr of the form expr-cond? expr-true: expr-false: · The definite assignment state of v before expr-cond is the same as the state of v before expr. · The definite assignment state of v before expr-true is definitely assigned if and only if one of the following holds: o expr-cond is a constant expression with the value false o the state of v after expr-cond is definitely assigned or “definitely assigned after true expression”. · The definite assignment state of v before expr-false is definitely assigned if and only if one of the following holds: o expr-cond is a constant expression with the value true · the state of v after expr-cond is definitely assigned or “definitely assigned after false expression”. · The definite assignment state of v after expr is determined by: o If expr-cond is a constant expression (§7.19) with value true then the state of v after expr is the same as the state of v after expr-true. o Otherwise, if expr-cond is a constant expression (§7.19) with value false then the state of v after expr is the same as the state of v after expr-false. o Otherwise, if the state of v after expr-true is definitely assigned and the state of v after expr-false is definitely assigned, then the state of v after expr is definitely assigned. o Otherwise, the state of v after expr is not definitely assigned. Anonymous functions For a lambda-expression or anonymous-method-expression expr with a body (either block or expression) body: · The definite assignment state of an outer variable v before body is the same as the state of v before expr. That is, definite assignment state of outer variables is inherited from the context of the anonymous function. · The definite assignment state of an outer variable v after expr is the same as the state of v before expr. The example delegate bool Filter(int i); void F() { // Error, max is not definitely assigned max = 5; generates a compile-time error since max is not definitely assigned where the anonymous function is declared. The example delegate void D(); void F() { d(); // Error, n is not definitely assigned also generates a compile-time error since the assignment to n in the anonymous function has no affect on the definite assignment state of n outside the anonymous function.
Variable references A variable-reference is an expression that is classified as a variable. A variable-reference denotes a storage location that can be accessed both to fetch the current value and to store a new value. variable-reference: In C and C++, a variable-reference is known as an lvalue.
|
||||
Последнее изменение этой страницы: 2016-08-10; просмотров: 249; Нарушение авторского права страницы; Мы поможем в написании вашей работы! infopedia.su Все материалы представленные на сайте исключительно с целью ознакомления читателями и не преследуют коммерческих целей или нарушение авторских прав. Обратная связь - 18.117.100.82 (0.004 с.) |