liveBook · Manning

Operand

As explained in Building User-Friendly DSLs

A subexpression that supplies an input to an operation, such as the left or right input of a binary operation.

An operand is a subexpression that supplies an input to an operation. A binary operation combines two operands: the left operand and the right operand. Each operand evaluates to a value, such as a discount percentage or rental price. section 11.1 section 11.6

Operand placement depends on the operator notation:

  • Infix notation places the operator between two operands, as in 1 / 2. section 11.1
  • Prefix notation places the operator before its operand or operands, as in ! false or - 42. section 11.1
  • Postfix notation places the operator after its operand or operands, as in i++ or j--. section 11.1

Calculating a rental discount

The expression “20% of $60” has two operands: the discount percentage and the rental price before discount. The “of” operator combines them and produces $12. In an expression model, these operands can be represented as subexpressions for attribute references or other operations. section 11.1 section 11.6

Table 11.1 Expression concepts and their properties
Concept
Arity (properties containing subexpressions)
Other properties
Attribute Reference
0
"attribute" (a reference to an Attribute)
Binary Operation
2 ("left operand", "right operand")
"operator" (a value from a small, fixed set of strings)
Number
0
"value" (a string that represents a number value)

Compare expression concepts by arity and identify the two operand properties that make Binary Operation a binary expression. section 11.5.1

How Building User-Friendly DSLs covers it

How deep it goes
Defines operands through binary-operation structure, operator notation, arity, and AST properties without covering evaluation internals.
Examples
Uses rental discount calculations, arithmetic, logical, comparison, prefix-negation, and postfix-increment expressions.
What it assumes
Assumes basic familiarity with expressions and introduces operand terminology through concrete binary-operation examples.
What you can do after
Evaluate operand roles by identifying each input, its position, its type, and the operation's result type.
How it connects
Connects operands to expressions, binary operations, operators, arity, abstract syntax trees, and attribute references.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Building User-Friendly DSLs. The section links point to the parts of the book it draws on.