Why does a programming language need keywords?

前端 未结 13 707
野性不改
野性不改 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:38

    Then what will the computer do when it comes across a statement like:

    while(1) {
      ...
      if (condition)
        break;
    }
    

    Should it actually break? Or should it treat it as 1;?

    The language would become ambiguous in certain cases, or you'd have to create a very smart parser that can infer subtle syntax, and that's just unnecessary extra work.

提交回复
热议问题