Discriminator

method of distinguishing elements with the same identifier in computing

Uses your system voice; voice and rate in settings.

Q5282088Snapshot

≈ 2 min read

Names in other languages

  • ČeštinaDiscriminator
  • EnglishDiscriminator
  • العربيةمميز (حوسبة)
  • فارسیمتمایزکننده
  • 中文鉴别器

Article bodies are English and are not machine-translated. A name in another language is not a translation of the article.

In computing, a discriminator is a field of characters designed to separate a certain element from others of the same identifier. As an example, suppose that a program must save two unique objects to memory, both of whose identifiers happen to be .

To ensure the two objects are not conflated, the program may assign discriminators to the objects in the form of numbers; thus, and distinguish both objects named . This has been adopted by programming languages as well as digital platforms for instant messaging and massively multiplayer online games. union Register switch (char) { case 'a': case 'b': short AX; case 'c': long EAX; default: octet AL; }; The effective value of the Register type may contain AX as the selected field, but the discriminator value may be either 'a' or 'b' and is stored in memory separately.

Therefore, IDL logically separates information about the currently selected field name and the union effective value from information about the current discriminator value. In the example above, the discriminator value may be any 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 the use of the remaining characters as well. { "$type": "book", "title": "Do Androids Dream of Electric Sheep?", "author": "Philip K. Dick" } A serialization of a movie. { "$type": "movie", "title": "Titanic", "director": "James Cameron" } Both data serializations share a common field here named "$type" which serves as the type discriminator.

The book have the book-specific field "author", while the movie have the movie-specific field "director". This facilitates the deserialization of data to different classes depending on the value of the type discriminator.

Text derived from https://en.wikipedia.org/w/index.php?oldid=1332286315 under CC BY-SA 4.0; modifications have been made.

Provenance

snapshot discriminator-601690-15e5fea50b8cfb51 · hash 15e5fea50b8cfb515413fcb06fa2e2505e0dd3de7ad2d42649e0c258caa0d29f · captured 1768088307.0 · version history

Cite this page as: encyclopegia.org, “Discriminator”, snapshot discriminator-601690-15e5fea50b8cfb51. https://encyclopegia.org/a/discriminator

Sources cited in this revision

8 named source(s) extracted from the cited revision. A source with no author is shown by its publication; nothing is invented.