> Is there something that works like AINSERT, but processes its operand
> immediately rather than buffering it until return to open code?

There is nothing like that at present.

The existing AINSERT was relatively simple to implement, in that
the inserted text is simply queued to be processed as open code
in the normal way, after any current macro generation processing
has completed.  (There were however overlooked complications in
the interaction with lookahead and processing of sequence
symbols, which took many years to resolve).

The idea of trying to process an AINSERT immediately has been
requested many times, but it is difficult even to define what
the language rules would be in that case, and the implementation
would appear to require a whole new set of concepts.

Macro definition is like compiling the macro to an executable
form, and macro generation interprets that executable form.  If
AINSERT were to operate in the context of the macro, that would
be similar to expecting to be able to provide a source statement
in a run-time variable for a compiled programming language.  The
REXX language can do that using the Interpret statement, but the
interpreter already existed in that case.

If instead AINSERT were to operate in a new context called by
the macro, that would have to work like another level of macro
call, effectively working like defining and executing a dynamic
macro, but in that case it is not clear what the scope would be
for any conditional assembly variables or sequence symbols, and
it is not clear how the calling macro could pick up any results.
Also, this would need some special indicator for multi-line
AINSERT, as if each line was executed immediately, it would not
for example be possible to declare some global variable and to
set it in the same scope.

If a top-level macro needs to simulate an immediate AINSERT,
then one method that I have seen successfully used is to AINSERT
a sequence that processes the dynamically substituted code
then reinvokes the same macro with an additional operand or a
global flag to indicate that it is being resumed, then exit to
allow the sequence to be processed.

Jonathan Scott, HLASM
IBM Hursley, UK

Reply via email to