RosettaCodeData/Task/Generic-swap/Slate/generic-swap-1.slate
Ingy döt Net d066446780 langs a-z
2013-04-10 22:43:41 -07:00

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
].