TAILIEUCHUNG - Lecture Programming languages (2/e): Chapter 8b - Tucker, Noonan

Chapter 8b - Semantics with dynamic typing. Here we consider the semantics of a dynamically typed language in order to examine the difference between statically and dynamically typed languages more fully. We use the same method of presentation as in section . | Programming Languages 2nd edition Tucker and Noonan Chapter 8 Semantic Interpretation To understand a program you must become both the machine and the program. A. Perlis Contents State Transformations and Partial Functions Semantics of Clite Semantics with Dynamic Typing A Formal Treatment of Semantics Dynamically Typed Languages Scripting: Perl, Python, PHP Object-oriented: Smalltalk, Ruby Functional: Scheme, ML, Haskel Logic: Prolog Our example: dynamically typed C++Lite int main( ) { n =3; i =1; f = ; while (i < n) { i = i + 1; f = f * float(i); } } Step Stmt n i f 1 3 -- -- -- 2 4 3 -- -- 3 5 3 1 -- 4 6 3 1 5 7 3 1 6 8 3 2 7 6 3 2 8 7 3 2 Step Stmt n i f 9 8 3 3 10 6 3 3 11 10 3 3 Perl vs. Python Perl: implicit conversions, distinct operators “2” < “10” : true – numeric comparison “2” lt “10” : false – string comparison 2 lt “10” : false – 2 converted to “2” Python: explicit conversions required “2” < “10” : false – string comparison 2 < “10” : error Meaning Rule The meaning of a Program is the meaning of its body when given an empty initial state. Variables declared as encountered Type of a variable is type of is value In factorial: i, n – int f – float C++Dynamic Statement = Skip

TỪ KHÓA LIÊN QUAN
TAILIEUCHUNG - Chia sẻ tài liệu không giới hạn
Địa chỉ : 444 Hoang Hoa Tham, Hanoi, Viet Nam
Website : tailieuchung.com
Email : tailieuchung20@gmail.com
Tailieuchung.com là thư viện tài liệu trực tuyến, nơi chia sẽ trao đổi hàng triệu tài liệu như luận văn đồ án, sách, giáo trình, đề thi.
Chúng tôi không chịu trách nhiệm liên quan đến các vấn đề bản quyền nội dung tài liệu được thành viên tự nguyện đăng tải lên, nếu phát hiện thấy tài liệu xấu hoặc tài liệu có bản quyền xin hãy email cho chúng tôi.
Đã 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.