We ordinarily view the world as populated by independent objects, each
of which has a state that changes over time. An object is said to
have state
if its behavior is influenced by its history.
A bank account, for example, has state in that the answer to the question
Can I withdraw $100?
depends upon the history of
deposit and withdrawal transactions. We can characterize an
object's state by one or more
state variables, which among them maintain enough
information about history to determine the object's current behavior.
In a simple banking system, we could characterize the state of an
account by a current balance rather than by remembering the entire
history of account transactions.
私たちは普段、世界を独立したオブジェクトの集まりとして捉えています。それぞれのオブジェクトは、時間とともに変化する状態を持っています。オブジェクトが状態を持つ
とは、その振る舞いが過去の履歴に影響されることを意味します。たとえば、銀行口座は状態を持っています。$100を引き出せますか?
という質問の答えは、過去の入金や出金の履歴に依存するからです。オブジェクトの状態は、1つまたは複数の
状態変数によって特徴づけることができます。状態変数は、オブジェクトの現在の振る舞いを決定するのに十分な履歴情報を保持します。単純な銀行システムでは、口座の全取引履歴を記憶する代わりに、現在の残高によって口座の状態を特徴づけることができるでしょう。
In a system composed of many objects, the objects are rarely
completely independent. Each may influence the states of others
through interactions, which serve to couple the state variables of one
object to those of other objects. Indeed, the view that a system is
composed of separate objects is most useful when the state variables
of the system can be grouped into closely coupled subsystems that are
only loosely coupled to other subsystems.
多くのオブジェクトで構成されるシステムでは、オブジェクトが完全に独立していることはほとんどありません。それぞれのオブジェクトは相互作用を通じて他のオブジェクトの状態に影響を与えることがあり、その相互作用によって、あるオブジェクトの状態変数が他のオブジェクトの状態変数と結合します。実際、システムが個別のオブジェクトの集まりであるという見方が最も有用なのは、システムの状態変数を、密に結合したサブシステムにグループ化でき、かつそれらのサブシステム同士は疎に結合している場合です。
This view of a system can be a powerful framework for organizing
computational models of the system. For such a model to be modular,
it should be decomposed into computational objects that model the
actual objects in the system. Each computational object must have its
own local state variables describing the actual object's
state. Since the states of objects in the system being modeled change over
time, the state variables of the corresponding computational objects
must also change. If we choose to model the flow of time in the
system by the elapsed time in the computer, then we must have a way to
construct computational objects whose behaviors change as our programs
run. In particular, if we wish to model state variables by ordinary
symbolic names in the programming language, then the language must
provide an
assignment operation
to enable us to change the value
associated with a name.
このようなシステムの見方は、システムの計算モデルを構成するための強力なフレームワークとなり得ます。そのようなモデルをモジュール化するには、システム内の実際のオブジェクトをモデル化する計算オブジェクトに分解すべきです。各計算オブジェクトは、実際のオブジェクトの状態を記述するための独自のローカル状態変数を持たなければなりません。モデル化されるシステム内のオブジェクトの状態は時間とともに変化するため、対応する計算オブジェクトの状態変数も変化しなければなりません。システムにおける時間の流れをコンピュータの経過時間でモデル化するならば、プログラムの実行に伴って振る舞いが変化する計算オブジェクトを構築する方法が必要です。特に、プログラミング言語の通常のシンボリックな名前で状態変数をモデル化したい場合、言語は名前に関連付けられた値を変更するための
代入演算
を提供しなければなりません。
3.1
Assignment and Local State
代入とローカル状態