Ref:  Your note of Thu, 18 Oct 2018 11:30:09 -0400

Steve Thompson writes:
> I have a question. If one passes too many positional arguments to
> a macro, should one not issue an MNOTE about this?
>
> Please try the following, and let me know what you think about this:
>
>       ESPIE SET,MYRTN,(1,3,7),PARAM=(3),MF(E,(1))

It is obviously possible for a macro to check for too many positional
arguments. There are also many other ways in which macros could
typically perform intelligent extra validation on operands.

However, on the other side, it is not normally the responsibility of the
macro writer to check for incorrect usage. Such checks could be
considered some "extra value" which the macro writer could add, if it is
considered worth while and does not add too much complexity.

The usual principle in most product macros is only to check for errors
which mean that the macro is unable to continue, for example because a
required operand is missing or a keyword has an unsupported value.

Personally, I include the "too many positional parameters" check in
most of the macros which I create.

I check for ('&SYSLIST(n)' EQ '') where n is one more than the valid
number of positional parameters.  I do this rather than checking
N'&SYSLIST so that it will tolerate a trailing comma, for example when
a macro has one positional parameter which is optional, so the user has
coded a dummy comma operand, which causes N'&SYSLIST to be set to 2 even
though only one positional operand is allowed.

Of course, my check will not pick up a case where a spurious extra
positional parameter is preceded by two or more consecutive commas,
but it doesn't seem worth coding multiple checks to cover even more
obscure possibilities.

Jonathan Scott, HLASM
IBM Hursley, UK

Reply via email to