[erlang-questions] abstract patterns vs macros was:( Floating guard sequences)
Fri Feb 20 00:15:20 CET 2009
On 20 Feb 2009, at 7:53 am, fess wrote:
> I'm sure I can learn something by asking, why not just do this with
Well, you could start by reading the paper.
One of the things abstract patterns were invented for is
to replace most uses of the preprocessor.
They can, for example, be syntax checked at the point of
*definition*, whereas macros can only be syntax checked
at the point of *use*. There are no problems with variable
name capture. Now that -type and -spec exist, they could
be given types. As things with run-time semantics, they
could be imported and exported just like functions (in fact
they would -be- functions of a rather limited kind). They
are bidirectional even in the presence of type tests.
As things with run-time semantics, inlining is one of
many compilation strategies, and they could be traced,
profiled, and debugged.
Right now, of course, macros are the closest approximation
to abstract patterns that are available.
More information about the erlang-questions