小弟最近在看很多sepc,注意到constant這個字好像跟我心目中的定義不太一樣。
我一直以為 3, 0x2A, 0b10001000這些就是所謂的constant
但看到這份文件: https://en.wikipedia.org/wiki/Constant_(computer_programming)#Comparison_with_literals_and_macros
Definition: a constant is a value that cannot be altered by the program during
normal execution
這段給我的感覺是,只要在normal exectuion的過程中,值不被改變就叫constant
問題一:什麼是normal execution?
接著文件又說: When associated with an identifier, a constant is said to be
"named," although the terms "constant" and "named constant" are often used
interchangeably.
這段告訴我的意思是,以下程式碼:
int a = 3;
只要a的值在normal execution過程中沒有被改變,那a就叫 named constant,並不叫
variable.
請問各位大大,我理解的方向是正確的嗎?