What is Context in programming )」?

Source: Internet
Author: User
I recently read the Flask document and read many terms about Context (Context), such as application Context and request Context. Can I check the information but cannot understand it? Is there a better explanation? I recently read the Flask document and read many terms about Context (Context), such as application Context and request Context. Can I check the information but cannot understand it? Is there a better explanation? Reply content:

Each program has many external variables. Only simple functions like Add do not have external variables. Once a program has external variables, the program is incomplete and cannot run independently. To make them run, you need to write some values to all external variables one by one. The set of these values is called context.


For example, in the lambda expression of C ++, [context is written here] (int a, int B ){...}.

Context is the snapshot of environment. You cannot find it because context is not a specific thing. context represents different meanings in different places and requires perceptual understanding.

Context is actually a plain text. It is similar to the context of the article. In terms of popularity, I think the environment is better.

....
Lin Chong shouted, "Oh, too !"
....

Q: In this sentence, Lin Chong's "Ah," expressed Lin Chong's mind?
A: Ah, your mom!

See, an article that can be excerpted for you. You don't understand it before or after, because there is a context, that is, the language environment exists, and what has it said, it must be inferred by context (the context of the article.

A subroutine is a truth for a program, a process for an operating system, or even a screen of an app for an app.

The program executes some subprograms. To obtain the results, the subprograms must use some previous results (including but not limited to external variable values and external objects );

The app clicks a button to enter a new interface, and stores the information such as the screen on which you jumped, so that you can jump back correctly when you click the returned result, if it is not stored, it cannot be jumped back correctly.

These are typical examples of context, which can be understood as the environment. (Although the context is called context, it is generally only mentioned above in the program, but it is called context .. Process interruptions exist in the operating system, but do not tell the subject to avoid new problems.) There is no difference between process interruptions and other input object parameters.

However, Context is usually used to describe the following features:
  1. Components that are passed in the Context must frequently obtain the data of the Context and call the function. It has a strong dependency on context and is implemented based on context.
  2. The Context is required by most components. In the software implementation part of the Context, a single instantiation occurs under a specific scene and is called by Multiple Component instance objects. Local regionalization occurs.
  3. Context will hold a lot of status data.
  4. Coder is used to naming products that are difficult to choose.

In addition, I promise not to beat you when the Context is translated into Chinese. Other languages are unknown.
The complete expression in Scheme should be the context of e in E, where E is an expression and e is a subexpression of this expression.
For example, if (+ 1 2 3) contains a subexpression 2, 2 has a context in (+ 1 2 3.
In Scheme, context is a process (a function ).
It is easy to construct this function. The first step is to dig out the subexpression and occupy the position with holes.
(+ 1 ~ 3 ),~ Empty.
Step 2: Wrap the result in the previous step with lambda to get the function.
(Lambda (~) (+ 1 ~ 3 )). That is, the context of 2 in (+ 1 2 3.
Similarly, the context (+ 2 3) in (/(+ 2 3) 4) is a function (lambda (~) (/~ 4 )).

The context has a property. When the original subexpression is used to call the context, the original expression is obtained.
(Lambda (~) (+ 1 ~ 3) 2); => (+ 1 2 3)
(Lambda (~) (/~ 4) (+ 2 3); => (/(+ 2 3) 4)

Because context has this property, it is easy to use context to explain the concepts of fixed point (y combination sub) and continuation. In linguistics, semantic Learning (semantics) does not contain context, while semantics (pragmatics) takes into account the influence of context on semantics.

In programming, some programming components (such as functions) must take into account the current compiling/running environment to understand its meaning/running results. If you understand the stateless concept, you will not be confused. Based on sessions, communication between each processing module requires a Session Identification identifier to be exchanged with the content container. That is, context. Generally, you want to have an object to save the state. If you don't have a good name, you can call context. Simply put, it is a state. When you interact with other modules, when other modules are finished notifying you, you can use context to know the status of your module before interaction, and then you can handle the status accordingly.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.