The New C Standard- P15

Tham khảo tài liệu 'the new c standard- p15', công nghệ thông tin, kỹ thuật lập trình phục vụ nhu cầu học tập, nghiên cứu và làm việc hiệu quả | Selection statements 1740 might have to be written as 1 2 x y 3 if x 0 4 . 5 Neither of these reasons could be said to contain an actual benefit. The cost associated with side effects in controlling expressions is the possibility that they will go unnoticed by a reader of the source especially if scanning along the left edge looking for assignments . The most common form of side effect in a controlling expression is assignment in particular simple assignment. The case where the author of the code intended to type an equality operator rather than a simple assignment operator is a fault and these coding guidelines are not intended to recommend against the use of constructs that are obviously faults. However it is possible that a reader of the visible source will mistake a simple assignment for an equality operator the token is much more likely than in the context of a controlling expression and reducing the likelihood of such a mistake occurring is also a cost reduction. This discussion has referred to controlling expressions as if these costs and benefits apply to their use in all contexts . selection and iteration statements . The following example shows that writing code to avoid the occurrence of side effects in controlling expressions contained with iteration statements requires two rather than one assignments to be used. 770 reading kinds of o guidelines not faults controlling expression if statement 1740 1 extern int glob_1 2 glob_2 3 4 void f_1 void 5 6 if glob_1 glob_2 7 8 while glob_1 glob_2 1 3 9 . 10 ii 12 void f_2 void 13 14 15 glob_1 glob_2 Single statement. 16 if glob_1 0 17 18 19 20 glob_1 glob_2 1 Statement 1 always occurs. 21 while glob_1 3 22 23 . 24 glob_1 glob_2 1 Statement 2 occurs after every iteration. 25 26 Duplicating the assignment to glob_1 creates a maintenance dependency any changes to one statement need to be reflected in the other . The increase in cost caused by this maintenance dependency is assumed to be greater than the .

Không thể tạo bản xem trước, hãy bấm tải xuống
TỪ KHÓA LIÊN QUAN
TÀI LIỆU MỚI ĐĂNG
Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.