In
programming, a tag is an
argument
An argument is a statement or group of statements called premises intended to determine the degree of truth or acceptability of another statement called conclusion. Arguments can be studied from three main perspectives: the logical, the dialectic ...
to a
subroutine
In computer programming, a function or subroutine is a sequence of program instructions that performs a specific task, packaged as a unit. This unit can then be used in programs wherever that particular task should be performed.
Functions may ...
that determines other arguments passed to it, which is used as a way to pass indefinite number of tagged parameters to the subroutine; notably, tags are used for a number of system calls in
AmigaOS v2.0 and onwards.
In AmigaOS
In earlier versions of
AmigaOS, if a system call required setting a large number of parameters, instead of passing them as function arguments, the function would require a pointer to a
structure
A structure is an arrangement and organization of interrelated elements in a material object or system, or the object or system so organized. Material structures include man-made objects such as buildings and machines and natural objects such as ...
that holds the arguments (for example,
intuition.library
Intuition is the native windowing system and user interface (UI) engine of AmigaOS. It was developed almost entirely by RJ Mical. Intuition should not be confused with Workbench, the AmigaOS desktop environment and spatial file manager, which re ...
's
OpenWindow()
required
struct NewWindow
with 17 different parameters). Tags were introduced in AmigaOS 2.0 because they "make it possible to add new parameters to system functions without interfering with the original parameters. They also make specifying parameter lists much clearer and easier."
A number of
third-party software libraries for AmigaOS also use tags extensively.
Example
The code without tags is obscure (for example,
0, 1
define window colors) while the code with tags is self-documenting. Fewer parameters have to be defined with tags than are in the structure, as OpenWindowTags will fall back to default parameters.
Implementation
AmigaOS provides functions for tag handling in its
utility.library
.
In general
An advantage of tags is that they ease the work with
default arguments since the programmer doesn't have to specify them or their substitutes. From this follows another advantage, ease of achieving of both
forward
Forward is a relative direction, the opposite of backward.
Forward may also refer to:
People
* Forward (surname)
Sports
* Forward (association football)
* Forward (basketball), including:
** Point forward
** Power forward (basketball)
** Sm ...
and
backward compatibility
Backward compatibility (sometimes known as backwards compatibility) is a property of an operating system, product, or technology that allows for interoperability with an older legacy system, or with input designed for such a system, especially i ...
with external
libraries: a program written for an older version of the library will work with a newer one, since the newer library will simply set all the parameters not provided by the program to their default values; and a program written for a newer version of the library will still work with the older version, since the older library will simply pay no attention to the newly introduced tags.
A disadvantage of tags is that their processing is slower than simply reading data from a
structure
A structure is an arrangement and organization of interrelated elements in a material object or system, or the object or system so organized. Material structures include man-made objects such as buildings and machines and natural objects such as ...
or the
stack
Stack may refer to:
Places
* Stack Island, an island game reserve in Bass Strait, south-eastern Australia, in Tasmania’s Hunter Island Group
* Blue Stack Mountains, in Co. Donegal, Ireland
People
* Stack (surname) (including a list of people ...
. Additionally,
compile time
In computer science, compile time (or compile-time) describes the time window during which a computer program is compiled.
The term is used as an adjective to describe concepts related to the context of program compilation, as opposed to concept ...
type checking is lost.
See also
*
Named parameter
In computer programming, named parameters, named argument or keyword arguments refer to a computer language's support for function calls that clearly state the name of each parameter within the function call.
Overview
A function call using name ...
References
External links
utility.library autodoc
{{AmigaOS
AmigaOS
MorphOS