Why does a programming language need keywords?

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

    The compiler would have problems if you write something like this:

    while(*s++);
    return(5);
    

    Is that a loop or a call to a function named while? Did you want to return the value 5 from the current function, or did you want to call a function named return?

    It often simplifies things if constructs with special meaning simply have special names that can be used to unambiguously refer to them.

提交回复
热议问题