tailieunhanh - Concepts, Techniques, and Models of Computer Programming - Chapter 6

Explicit State Ngay từ cái nhìn đầu tiên, rõ ràng nhà nước chỉ là một phần mở rộng nhỏ để lập trình khai báo: ngoài việc phụ thuộc vào đối số của nó, kết quả của thành phần cũng phụ thuộc vào một tham số nội bộ, được gọi là "nhà nước". Tham số này cung cấp cho các thành phần một bộ nhớ dài hạn, một "ý nghĩa lịch sử" nếu bạn Nếu không có nhà nước, một thành phần chỉ có bộ nhớ ngắn hạn, một trong những tồn tại trong một lời gọi cụ thể. | Chapter 6 Explicit State L etat c est moi. I am the state. - Louis XIV 1638-1715 If declarative programming is like a crystal immutable and practically eternal then stateful programming is organic it grows and evolves as we watch. - Inspired by On Growth and Form D Arcy Wentworth Thompson 1860-1948 At first glance explicit state is just a minor extension to declarative programming in addition to depending on its arguments the component s result also depends on an internal parameter which is called its state . This parameter gives the component a long-term memory a sense of history if you Without state a component has only short-term memory one that exists during a particular invocation of the component. State adds a potentially infinite branch to a finitely running program. By this we mean the following. A component that runs for a finite time can only have gathered a finite amount of information. If the component has state then to this finite information can be added the information stored by the state. This history can be indefinitely long since the component can have a memory that reaches far into the past. Oliver Sacks has described the case of people with brain damage who only have a short-term memory 161 . They live in a continuous present with no memory beyond a few seconds into the past. The mechanism to fix short-term memories into the brain s long-term storage is broken. Strange it must be to live in this way. Perhaps these people use the external world as a kind of long-term memory This analogy gives some idea of how important state can be for people. We will see that state is just as important for programming. 1 Chapter 5 also introduced a form of long-term memory the port. It was used to define port objects active entities with an internal memory. The main emphasis there was on concurrency. The emphasis of this chapter is on the expressiveness of state without concurrency. Copyright 2001-3 by P. Van Roy and S. Haridi. All rights reserved. 414 .

TỪ KHÓA LIÊN QUAN