Discriminator
Encyclopedia
Discriminator is a typed tag field present in OMG
Object Management Group
Object Management Group is a consortium, originally aimed at setting standards for distributed object-oriented systems, and is now focused on modeling and model-based standards.- Overview :...

 IDL
Interface description language
An interface description language , or IDL for short, is a specification language used to describe a software component's interface...

 discriminated union
Tagged union
In computer science, a tagged union, also called a variant, variant record, discriminated union, or disjoint union, is a data structure used to hold a value that could take on several different, but fixed types. Only one of the types can be in use at any one time, and a tag field explicitly...

 type and value definitions that determines which union member is selected in the current union instance. Unlike in some conventional programming languages offering support for unions, discriminator in IDL is not identical to selected field name. Here is an example of IDL union type definition:


union Register switch (char)
{
case 'a':
case 'b': short AX;

case 'c': long EAX;

default: octet AL;
};


Effective value of the Register type may contain AX as selected field, but discriminator value may be either 'a' or 'b' and it is stored in memory separately. Therefore, IDL logically separates information about currently selected field name and union effective value from information about current discriminator value. In the example above, discriminator value may be anything of the following: 'a', 'b', 'c', as well as all other characters belonging to the IDL char type, since the default branch specified in the example Register type allows use of the remaining characters as well.

Other languages

The Microsoft Interface Definition Language also supports tagged unions, allowing to choose the discriminator via an attribute
Java annotation
An annotation, in the Java computer programming language, is a special form of syntactic metadata that can be added to Java source code. Classes, methods, variables, parameters and packages may be annotated...

in an enclosing structure or function.
The source of this article is wikipedia, the free encyclopedia.  The text of this article is licensed under the GFDL.
 
x
OK