1.9. Semantic Errors


The third type of error is the semantic error. If there is a semantic error in your program, it will run successfully in the sense that the computer will not generate any error messages. However, your program will not do the right thing. It will do something else. Specifically, it will do what you told it to do.
The problem is that the program you wrote is not the program you wanted to write. The meaning of the program (its semantics) is wrong. Identifying semantic errors can be tricky because it requires you to work backward by looking at the output of the program and trying to figure out what it is doing.

Loại lỗi thứ 3 là lỗi về mặt ngữ nghĩa. Nếu có một lỗi ngữ nghĩa trong chươgn trình của bạn, nó sẽ chạy thành công trong trường hợp này máy tính sẽ không đưa ra thông báo nào chung về lỗi. Tuy nhiên, chương trình của bạn sẽ không làm đúng. Nó sẽ làm vài điều khác. Cụ thể, nó sẽ làm cái mà bạn nó làm.
Vấn đề là chương trình bạn đã viết không phải là chương trình mà bạn MUỐN viết. Nghĩa là chương trình (về mặt ý nghĩa) là sai. Xác định lỗi ngữ nghĩa có thể cần "láu cá" bởi vì nó yêu cầu bạn phải làm trở lại bằng cách xem kỹ đầu ra của chương trình và thử tìm ra cái gì đang diễn ra.
References:

http://interactivepython.org/runestone/static/thinkcspy/index.html

Nhận xét

Bài đăng phổ biến từ blog này

2.7. Operators and Operands - toán tử và toán hạng

1.11. Formal and Natural Languages

3.10 Stack diagrams - sơ đồ xếp chồng