Please enable JavaScript to view this site.

A-Shell Reference

Written July 2023

While the standard method of passing parameters By Value is sensible for individual scalar parameters, it isn't practical for entire arrays and collections. Instead, these are passed "by reference", meaning that rather than copying the value from the source to the target, a reference is passed instead. The effect is make the array or collection within the called routine essentially an alias of the array or collection in the calling routine. In this case, the inputonly or outputonly modifiers wouldn't make any sense.

Note that passing parameters by reference, there is no opportunity for data type conversions to take place. In general it is left to the programmer to make sure that the source and destination types are compatible, but in the case of collections, to avoid hard-to-debug or otherwise catastrophic mismatches, the compiler does enforce certain rules.  See Mismatched Collection Arrays for details.

dimx kindergarden(0), ST_STUDENTS, auto_extend

    ...

call Fn'Field'Trip(kindergarten())

    ...

 

Function Fn'Field'Trip(class() as ST_STUDENTS)

    ...

EndFunction

 

In the above example, the entire dynamic array kindergarden() is passed by reference to the function, where it is referenced by the local name class().  Any changes made to class() within the function, including extending (or otherwise redimensioning the array) will be directly reflected in the source array kindergarten(). The use of XPUTARG does not apply.

History

2023 August, A-Shell 6.5.1740:  DIMX arrays of type S or X are now treated as compatible with each other when passed by reference to a function. Previously this triggered an incompatible parameter error.

Subtopics

Passing DIMX Arrays

Passing Collections I