Phillip Helbig <[log in to unmask]> wrote:
...
> [...] I like the idea of @ introducing a
>macro, something like
>
> MACRO FOO
> <insert code here>
> END MACRO FOO
>
>then @FOO in the code. This would essentially be like INCLUDE, except
>that FOO is defined within the routine in which it is used. (When PART
>of a format statement is repeated a number of times would be a nice use
>for this, among others.)
I've been using @ for simple text substitution macros for years:
@slice = (1:N:2, 3:M)
...
A@slice = B@slice/2
This eliminates the need for any pointers when all I want
is a shorthand for commonly used array slices. It could
be used elsewhere, as you point out.
The preprocessor is easy. Any line whose first non-blank
character is @ is interpreted as a macro definition. The
next identifier (letter followed by alphanumberics, including
underscore) is the macro name. Then there must be an equal
sign.(possibly with spaces). Whatever is after that is the
macro body. Anywhere else, the @ is interpreted as a
macro call (including inside character context - a simple
preprocessor), and the call is replaced with the corresponding
text.
--
J. Giles
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|