Does anyone know the reason why the variables have to be defined at the top of function

前端 未结 5 767
遥遥无期
遥遥无期 2021-02-09 14:18

I have a question, does anyone know why the variables have to be defined initialized at the beginning of a function? Why can\'t you initialize or define variables in the

5条回答
  •  灰色年华
    2021-02-09 15:10

    Try writing a compiler with the primitive power of the old times and you'd realize flexibility is something you'd rather kill to get the software to work.

    Putting variables first, then other statements simply made their parser/compiler code simpler.

提交回复
热议问题