How are operators called which affect the first operand instead of 'return' something?
I'm talking about operators which not return a value but modify (overwrite) the first operand.
Example in pseudo-code:
add := return op1 + op2
increment := op1 = op1 + op2
Given this mapping schema:
add -> increment
subtr开发者_Python百科act -> decrement
What could possibly be the names for other operators?
multiply, divide, power, ... (what else?)
I was thinking about add->selfAdd
, multiply->selfMultiply
, but these names are somehow stupid.
NOTE: What's all this for? It's for an experimental programming language. Because of certain circumstances there may be only words, no operator signs, so I can't use ++
for increment
or *=
for selfMultiply
.
I've usually heard *= and += referred to as "multiply-assign" and "add-assign".
I believe you are describing the differences between unary and binary operators/operations.
This document about Java operators names them compound assignment operators:
You can also combine the arithmetic operators with the simple assignment operator to create compound assignments. For example, x+=1; and x=x+1; both increment the value of x by 1.
精彩评论