Patterns of Argument Passing

Uwe Zdun · 2005

Argument passing means passing values along with an invocation. Most programming languages provide positional arguments as their ordinary argument passing mechanism. Sometimes ordinary argument passing is not enough, for instance, because the number of arguments or their types dier from invocation to invocation, or optional arguments are needed, or the same arguments are passed through a chain of multiple receivers and must vary exibly. These issues can be resolved using ordinary argument pass-ing mechanisms, but the solutions are usually cumbersome. In many systems, such as programming languages, programming environments, frameworks, and middleware systems, advanced argument passing solutions are provided to better address these is-sues. In this paper we present four patterns applied in these advanced argument passing solutions: variable argument lists allow an operation to receive arbitrary numbers of arguments, optional arguments let operations have arguments which can either be provided in an invocation or not, non-positional arguments allow arguments to be passed in any order as name/value pairs, and context objects are special types used for the purpose of argument passing.

Read the paper · More papers on PaperTik