Why does a programming language need keywords?

前端 未结 13 699
野性不改
野性不改 2021-02-01 03:25

For example (in C):

int break = 1;
int for = 2;

Why will the compiler have any problems at all in deducing that break and fo

13条回答
  •  北恋
    北恋 (楼主)
    2021-02-01 03:51

    several reasons:

    • The keywords may seem unambiguous in your samples. But that is not the only place you would use the variable 'break' or the variable 'for'.

    • writing the parser would be much harder and error prone for little gain.

    • using a keyword as a function or procedure name in a library may have undesired, possibly security relevant, side effects.

提交回复
热议问题