[cs13001] Making sure what an expression is.

Mikhail Nesterenko mikhail at cs.kent.edu
Tue Sep 25 19:06:58 EDT 2012


> 
> Would an expression be considered a value? Or would it be considered
> an argument?
> 
> It's on the right hand side, and it expresses the value that we
> want, so shouldn't it be a value?

An expression is a construct that is composed of sub-expressions by
means of operators. An operator accepts sub-expressions as operands. A
binary operand accepts two sub-expressions. An elementary form of
sub-expression is just a constant or a variable. For example this
expression

	       a*b + 22.3

consists of two sub-expressions: a*b and 22.3 joined by operator
"+". The first one is another expression (a*b) and the second one is a
literal constant.

Note that each expression has both a value and a type. The type of the
expression is known at compile-time (by the compiler). The value of
the expression may or may not be. 

For example, the value of this expression:   22.3 - 20 
is known and the value of this expression:   a + 20
is not.

An expression can be used as an argument in function invocation: sqrt(9.0 +2.0)
A function invocation may be used in an expression:

  	   sqrt(9.0) + 22.0

Thanks,
--
Mikhail


More information about the cs13001 mailing list