10 lines
410 B
Text
10 lines
410 B
Text
x@(Syntax LoadVariable traits) swapWith: y@(Syntax LoadVariable traits) &environment: env
|
|
"A macro that expands into simple code swapping the values of two variables
|
|
in the current scope."
|
|
[
|
|
env ifNil: [error: 'Cannot swap variables outside of a method'].
|
|
tmpVar ::= env addVariable.
|
|
{tmpVar store: x variable load.
|
|
x variable store: y variable load.
|
|
y variable store: tmpVar load} parenthesize
|
|
].
|