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

  • PHP Reactive Programming
  • Martin Sikora
  • 191字
  • 2021-07-09 19:06:14

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.
主站蜘蛛池模板: 观塘区| 永福县| 喀喇沁旗| 三门县| 金秀| 吉隆县| 南溪县| 商丘市| 微山县| 大城县| 临夏市| 苗栗市| 洛宁县| 福海县| 招远市| 河间市| 正安县| 洪泽县| 苗栗县| 明水县| 南充市| 南京市| 东乡族自治县| 茶陵县| 双鸭山市| 万宁市| 新昌县| 怀宁县| 定远县| 青冈县| 全椒县| 出国| 孙吴县| 荔波县| 台州市| 竹北市| 南澳县| 商水县| 靖宇县| 萨嘎县| 益阳市|