Macros swapo, swapi, swapd, swapa, swapv

Introduction

These macros allow you to swap the values of two variables.

Syntax


	swapo(var1, var2, type) => true
	swapo(var1, var2) => true
	swapi(var1, var2) => true
	swapa(var1, var2) => true
	swapd(var1, var2) => true
	swapv(var1, var2) => true

where:

Discussion

If type is passed, then the type of both variables must be compatible with receiving an instance of that type. Otherwise, for swapo each variable must be able to receive an untyped object; for swapi an integer; for swapa an alpha value; for swapd a decimal value; and for swapv a Var.

type may be a type cast such as (MyClass), a multiple cast such as (i)(var), or it can even be a method or function name that will be used to return the proper type. In the latter case, the routine must accept an argument of type object (@*).

These macros provide a good example of the usefulness of let and progn together.