官术网_书友最值得收藏!

Imperative programming

Imperative programming is a programming paradigm around executing statements that change the program's state.

What this means in human language:

  • Programming paradigm: This is a set of concepts defining a style of building and structuring programs. Most programming languages, such as PHP, support multiple paradigms. We can also think of it as a mindset and a way we approach problems when using such paradigms.
  • Statements: Units of action with side effects in imperative programming evaluated in sequences usually containing expressions. Statements are executed for their side effects and expressions for their return value. Consider this example:
            $a = 2 + 5 
    

    This line of code is a statement where 2 + 5 is an expression. The expected side effect is assigning the value 7 to the $a variable. This leads to changing the program's current state. Another statement could be, for instance:

            if ($a > 5) { } 
    

    This statement has one expression and no return value.

  • State: Values of program variables in memory at any given time. In imperative programming, we define a series of statements that control the program's flow and, therefore, change its state.
主站蜘蛛池模板: 遂宁市| 灵武市| 清苑县| 桂东县| 九寨沟县| 寿宁县| 双流县| 偏关县| 石城县| 福清市| 铜梁县| 牡丹江市| 常宁市| 黄冈市| 区。| 陵川县| 海城市| 囊谦县| 同心县| 巩义市| 易门县| 广东省| 新郑市| 本溪| 大连市| 大冶市| 昭平县| 江源县| 武安市| 万源市| 永丰县| 昌邑市| 峨眉山市| 旅游| 吉林市| 邢台市| 屯门区| 红原县| 滁州市| 塔河县| 灵石县|