0

I am studying order of evaluation of expressions and I came across this paragraph,

A constant expression is an expression that consists of only constant values. It is an expression whose value is determined at the compile-time but evaluated at the run-time. It can be composed of integer, character, floating-point, and enumeration constants.

Resource of paragraph: https://www.javatpoint.com/cpp-expression

Can someone elaborate what does determining a value & evaluating a value means ? aren't these the same. . .

Also, I landed to this paragraph after reading the following definition,

**Evaluation of Expressions

Evaluation of each expression includes:

value computations: calculation of the value that is returned by the expression. This may involve determination of the identity of the object (glvalue evaluation, e.g. if the expression returns a reference to some object) or reading the value previously assigned to an object (prvalue evaluation, e.g. if the expression returns a number, or some other value)

Initiation of side effects: access (read or write) to an object designated by a volatile glvalue, modification (writing) to an object, calling a library I/O function, or calling a function that does any of those operations.**

Resource: https://en.cppreference.com/w/cpp/language/eval_order

Kindly, explain (1) what does calculation of value means. An expression could be a function returning some value so what has to be calculated about that returned value?

(2) What does identification of an object means?

Hamza Khan
  • 21
  • 5
  • human readable tutorials necessarily have to use sloppy language. I don't know what that sentence is supposed to mean. You can read here for a description that follows the wording in the c++ standard more closely (at the cost of being less easy to grasp) https://en.cppreference.com/w/cpp/language/constant_expression – 463035818_is_not_an_ai Jul 26 '21 at 13:26
  • The Indian author is not a native English speaker. Originally the website was a Java tutorial. Both circumstances hint at C++ texts that are not language lawyer proof. – Peter - Reinstate Monica Jul 26 '21 at 13:31
  • 1
    The new questions should be made into, well, new questions. – Peter - Reinstate Monica Jul 26 '21 at 13:39
  • Source (JavatPoint) has several mistakes/approximations...: *"It is used in the pre-processor #if"*, preprocessor is an other beast which doesn't accept all constant expressions. *"We can use the static and extern keyword with the constants to define the function-scope."* declaration of variable is unrelated to constant expression... In their sentence, *"but evaluated at the run-time"* makes no sense for me. – Jarod42 Jul 26 '21 at 13:55
  • (1) __value computations__: I think the author is trying to summarise https://en.cppreference.com/w/cpp/language/expressions and most of the linked pages. This is probably impossible in 1 paragraph. – Richard Critten Jul 26 '21 at 14:48
  • (2) _"...What does identification of an object means?..."_ Probably (because guessing) [Name lookup - qualified and unqualified](https://en.cppreference.com/w/cpp/language/lookup), followed by determining it's [Value category](https://en.cppreference.com/w/cpp/language/value_category) – Richard Critten Jul 26 '21 at 14:54

0 Answers0