Anaphora

This library provides anaphoric macros for Dylan, but what’s an anaphoric macro?

From Wikipedia:

An anaphoric macro is a type of programming macro that deliberately captures some form supplied to the macro which may be referred to by an anaphor (an expression referring to another). Anaphoric macros first appeared in Paul Graham’s On Lisp and their name is a reference to linguistic anaphora — the use of words as a substitute for preceding words.

Anaphoric Macros

This library currently implements one macro, aif:

aif Macro
Macro Call:

aif (expression)
  body
[else else-body]
end;

Discussion:

A common Dylan idiom is to make functions return #f to indicate “no value” and any other value indicates success. Correspondingly, it is common to see code like the following:

let result = false-or-something-else();
if (result)
  foo(result)
end;

The aif macro automatically binds the variable it to the return value so that you can instead write:

aif (false-or-something-else())
  foo(it)
end;

or

aif (false-or-something-else())
  foo(it)
else
  bar()
end;

Indices and tables