Please enable JavaScript to view this site.

A-Shell Development History

The compiler now complains about mismatched collection arrays passed by reference to functions. For example, passing an ordmap to an ordmapm, or an ordmap(varstr;varx) to an ordmap(varstr;varstr).

Since there may be situations where it makes sense to take advantage of the compatibility overlap between different kinds of collections, you can now signal to the compiler that you want to allow such mismatches, by appending an asterisk to the collection name in the function declaration. For example, the "*" in this function declaration...

Function Fn'Foo($m as ordmap*(varstr;varx))

... causes the compiler to allow essentially any kind of collection to be passed to the function.

An example where this might make sense would be if you had an auxiliary function that traced the contents of a collection by iterating through it. A single copy of such a function could handle both ordmap and ordmapm, and quite possibly other collection type, as long as they supported iteration.

Notes

Since collections (as opposed to individual values within a collection) are passed by reference, the called function actually operates directly on the passed copy of the collection. So for example, even if the function was declared as receiving an ordmap, if the caller passes an ordmapm, then the function will operate on that ordmapm —i.e. it will support duplicate keys. That could lend useful flexibility, or introduce subtle bugs, which is why the default is now to treat it as a compilation error unless you explicitly request the flexibility with the asterisk.
The system previously triggered an error 63 (Func/Proc parameter type/size mismatch) for some of these mismatches. It now assumes that the programmer and compiler together weeded out the unintentional mismatches.
There is no problem (and no need for the asterisk) when passing a collection with an varstr value type to a function receiving it as a collection with a varx value type. Varx can faithfully represent any varstr value. But the reverse is not true, and requires the asterisk feature if you want to allow it.