On 2017-05-03, at 14:57, Michael Harding wrote:
>
> ...  Or in your example you could have kept going beyond the 4th
> argument but what's the point, you know they aren't specified.
>
It was just an astonishment (admittedly minor) that for:
    X = F(    , 'Z' )
in F, "SAY ARG() ARG( ARG(), 'E' )"
prints "2 1", but for:
    X = F( 'A',     )
in F, "SAY ARG() ARG( ARG(), 'E' )"
prints "1 1" where I'd expect "2 0".  (I just need to read the manual
very carefully.)

On 2017-05-03, at 14:48, Mark Boonie wrote:

> Small quibble -- Rexx does distinguish between a null string and an
> omitted string, to some extent, using the ARG(n, 'E') or ARG(n, 'O') forms
> of the ARG() function.  For example, Arg(4, 'E') returns 0 if the 4th
> argument was omitted, but it returns 1 if it was specified as a null
> string.  For parsing, of course, an omitted parameter is treated the same
> as a null string.
>
One might code, if it matters:
    IF ARG( n, 'E' ) THEN Arg.n = ARG( n )
                     ELSE DROP Arg.n

> The ARG() function with no parameters returns the number of the last
> explicitly specified argument (even if it was a null string).  As a
> result, there is no way to tell how many extra commas with omitted
> parameters were specified.
>
Yup.

And one can tell whether a subroutine returns a result with
    DROP RESULT
    CALL SUBR
    if SYMBOL( 'RESULT' )=='LIT' THEN DROP X
                                 ELSE X = RESULT
(assuming that SUBR doesn't have an internal call that sets RESULT
and EXPOSEs it.)

-- gil

Reply via email to