Tag (programming)

Tag (programming)

In programming, a tag is an argument to a subroutine 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 that holds the arguments (for example, intuition.library's OpenWindow() required struct NewWindow with 17 different parameters). Tags were introduced in AmigaOS 2.0 because:

Quote|Tags make it possible to add new parameters to system functions withoutinterfering with the original parameters.  They also make specifyingparameter lists much clearer and easier.||cite book|title=Amiga® ROM Kernal Reference Manual: Libraries|edition=3rd edition|ISBN=0-201-56774-1|url=http://cataclysm.cx/random/amiga/reference/Libraries_Manual_guide/node0496.html|pages=867

A number of third-party software libraries for AmigaOS also use tags extensively.

Example

Note how the code without tags is obscure (for example, 0, 1 define window colors) while the code with tags is self-documenting. Note also that 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 and backward compatibility 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 or the stack. Additionally, compile time type checking is lost.

External links

* [http://tbs-software.com/guide/index.php?guide=autodocs.doc%2Futility.doc utility.library autodoc]
* [http://cataclysm.cx/random/amiga/reference/Libraries_Manual_guide/node00B4.html Amiga® ROM Kernal Reference Manual: Libraries - Tag index]


Wikimedia Foundation. 2010.

Игры ⚽ Поможем сделать НИР

Look at other dictionaries:

  • Tag — or tagging may refer to:Personal identifiers*Dog tag, a small, flat, metal identification label attached to a dog collar *Dog tag (identifier), a small, flat, metal identification label worn around the neck of military personnel *Triage tag, a… …   Wikipedia

  • tag´ger — tag1 «tag», noun, verb, tagged, tag|ging. –n. 1. a card or small piece of paper, leather, or other material, to be tied or fastened to something, especially as a label: »Each coat in the store has a tag with the price on it. 2. a small hanging… …   Useful english dictionary

  • tag — tæg n. label; something which hangs loosely; phrase or nickname which characterizes something; (Computers) label which instructs the computer to display the text following it in a certain way (in the programming language HTML) v. furnish with a… …   English contemporary dictionary

  • Comparison of programming languages (syntax) — Programming language comparisons General comparison Basic syntax Basic instructions Arrays Associative arrays String operations …   Wikipedia

  • Comparison of programming languages (object-oriented programming) — Programming language comparisons General comparison Basic syntax Basic instructions Arrays Associative arrays String operations …   Wikipedia

  • Comparison of programming languages (basic instructions) — Programming language comparisons General comparison Basic syntax Basic instructions Arrays Associative arrays String operations …   Wikipedia

  • computer programming language — Introduction       any of various languages for expressing a set of detailed instructions for a digital computer. Such instructions can be executed directly when they are in the computer manufacturer specific numerical form known as machine… …   Universalium

  • Comment (computer programming) — For comments in Wikipedia markup, see Help:Wiki markup#Character formatting and WP:COMMENT. An illustration of Java source code with prologue comments indicated in red and inline comments in green. Program code is in blue …   Wikipedia

  • Java (programming language) — infobox programming language name = Java paradigm = Object oriented, structured, imperative year = 1995 designer = Sun Microsystems latest release version = Java Standard Edition 6 (1.6.0) latest release date = latest test version = latest test… …   Wikipedia

  • Lasso (programming language) — Infobox Software name = LASSO caption = developer = LassoSoft, LLC latest release version = 8.5.5 latest release date = March 20, 2008 operating system = Mac, Windows, Linux genre = Middleware Application Server license = Proprietary website =… …   Wikipedia

Share the article and excerpts

Direct link
Do a right-click on the link above
and select “Copy Link”