Added February 2025
Syntax one:
.ARG_READONLY(argno) or .ARG_PASSED(@arg)
Syntax two:
.ARG_READONLY(@arg) or .ARG_PASSED(argno)
These two dot functions indicate whether the specified argument is read-only, or was even passed to the current SBX, function, or procedure.
Parameters
argno (Unsigned int) [in]
The ordinal number of the argument being queried, starting from 1. Note that in the case of Named Parameters, the parameter numbers are determined by the function declaration or subroutine DEFXCALL directive, not necessarily by the order specified in the calling statement. If the argno passed is invalid, the return value of the function will be -1.
@arg (Literal parameter name) [in]
This syntax provides an alternate way to reference the parameter of interest by its format name rather than its ordinal number. The concept is similar to that used for XPUTARG @arg : @arg is treated by the compiler as a macro for the argument number corresponding to the argument @arg as defined in the function/procedure definition or as retrieved in an SBX using XGETARG(S).
The return value for .ARGSIZ is the size of the original argument in bytes.
The return value for .ARGTYP is a 16-bit bitmap value based on the following tables: one bit from the first table, zero or more bits from the second table.
Symbol |
Value |
Description |
---|---|---|
ARGTYP_MASK |
&h000f |
mask for types X,S,F,B,I |
ARGTYP_X |
&h0000 |
X type (mutually exclusive) |
ARGTYP_S |
&h0002 |
S type (" " ") |
ARGTYP_F |
&h0004 |
F type (" " ") |
ARGTYP_B |
&h0006 |
B type (" " ") |
ARGTYP_I |
&h0008 |
I type (" " ") |
Symbol |
Value |
Description |
---|---|---|
ARGTYP_ARRAY |
&h0010 |
Array |
ARGTYP_NOSURR |
&h0020 |
No surrogate |
ARGTYP_DYN |
&h0040 |
Dynamic variable |
ARGTYP_LOCAL |
&h0080 |
Local dynamic variable |
ARGTYP_SBR |
&h0100 |
Variable within SBX or XCALL AMOS |
ARGTYP_DIMX |
&h0200 |
Base of DIMX array passed by reference |
ARGTYP_READONLY |
&h0400 |
See ARGTYP_READONLY section below |
ARGTYP_COLL |
&h0800 |
Collection (e.g. ordered map, etc.) |
Comments
The return value is a BOOLEAN.
.ARG_READONLY() is logically equivalent to testing the ARGTYP_READONLY bit in the value returned by .ARGTYP()
.ARG_PASSED() returns .TRUE if the argument was actually passed by the caller, rather than auto-set via the default value specification in the function declaration. Note that although this function is fully resolved by the compiler, making it at least nominally backwards compatible, on runtime versions prior to 7.0.1767 it acts as the inverse of .ARGTYP_READONLY().
Example
call fn'foo(arg=9)
...
function fn'foo(arg=1 as b2)
? .ARG_READONLY(@arg) ! .TRUE in all cases
? .ARG_PASSED(@arg) ! .TRUE if > 7.0.1766, else FALSE
endfunction
The argument is readonly because it was passed as a literal value. The function could try to update it using XPUTARG(@arg1) but it would have no effect, since the value is on the stack.
But readonly or not, it was actually passed, which might be meaningful to the called function. However, prior to 7.0.1767, the runtime is unable to determine that, so it will the readonly status instead. From 1767 forward, the two flags are independent.
History
2025 January, A-Shell 7.0.1767, compiler edit 1051: Add support for .ARGTYP_READONLY and .ARGTYP_PASSED.