Concept (generic programming)

Concept (generic programming)

In generic programming, a concept is a description of supported operations on a type, including syntax and semantics. In this way, concepts are related to abstract base classes but concepts do not require a subtype relationship.

Contents

Languages using

The term was in use as early as 1998 for STL[1], as this was one of the first libraries that extensively used templates.

Primarily (in C++ 1998 standard), the Concept term was introduced to name just a simple description of the requirements for particular type, usually being a template parameter. It was never encoded in the language explicitly - the concept was expressed only by what operations are tried to be performed on objects of that type and what is expected to work (that is, to compile correctly).

As generics in Java and C# have some similarities to C++'s templates, the role of concepts there is played by interfaces. However there is one important difference between concepts and interfaces: when a template parameter is required to implement a particular interface, the matching type can only be a class that implements (explicitly) that interface. Concepts bring more flexibility because they can be satisfied by two ways:

  • explicitly defined as satisfied by using a concept map (defined separately to the type itself, unlike interfaces)
  • implicitly defined for "auto concepts", which can be used also for built in types and other types that were not predestined for this use

Another language implementing something very similar to concepts is Haskell, where the feature is called type classes.

Example

For example, if a type I satisfies the Trivial Iterator concept in C++, and i is of type I, the following are valid expressions with corresponding semantics:[2]

  • I i default construction.
  • *i must be convertible to some type T.
  • i->m is valid if (*i).m is.

See also

References

  1. ^ Austern, M.H. Generic programming and the STL: using and extending the C++ Standard Template Library. 1998. pp 17–18
  2. ^ Trivial Iterator

External links


Wikimedia Foundation. 2010.

Игры ⚽ Нужна курсовая?

Look at other dictionaries:

  • Generic programming — is a style of computer programming in which algorithms are written in terms of to be specified later types that are then instantiated when needed for specific types provided as parameters and was pioneered by Ada which appeared in 1983. This… …   Wikipedia

  • Concept map — For concept maps in generic programming, see Concept (generic programming). Example concept map, created using the IHMC CmapTools computer program. A concept map is a diagram showing the relationships among concepts. It is a graphical tool for… …   Wikipedia

  • Concept (disambiguation) — A concept is a cognitive unit of meaning an abstract idea or a mental symbol sometimes defined as a unit of knowledge . Concept may also refer to: Computing Concept (generic programming), a generic programming term In computational learning… …   Wikipedia

  • Concept-oriented design — (COD) is a theory of design and development based upon the language and diagrams of practitioners. It has been implemented in a tool Chasm to build 3D user interfaces (3DUIs). Its name is borrowed from the generic programming idea of a software… …   Wikipedia

  • concept — noun /ˈkɒn.sɛpt/ a) An understanding retained in the mind, from experience, reasoning and/or imagination; a generalization (generic, basic form), or abstraction (mental impression), of a particular set of instances or occurrences (specific,… …   Wiktionary

  • Programming paradigm — Programming paradigms Agent oriented Automata based Component based Flow based Pipelined Concatenative Concu …   Wikipedia

  • Programming in the large and programming in the small — Programming paradigms Agent oriented Automata based Component based Flow based Pipelined Concatenative Concurrent computin …   Wikipedia

  • Object-oriented programming — Programming paradigms Agent oriented Automata based Component based Flow based Pipelined Concatenative Concurrent computing …   Wikipedia

  • XL (programming language) — XL stands for eXtensible Language. It is a computer programming language designed to support concept programming.XL features programmer reconfigurable syntax and semantics. Compiler plug ins can be used to add new features to the language. A base …   Wikipedia

  • Eiffel (programming language) — Infobox programming language name = Eiffel paradigm = object oriented year = 1986 designer = Bertrand Meyer developer = Bertrand Meyer Eiffel Software latest release version = 4.2 latest release date = Feb 6, 1998 typing = static typing, strong… …   Wikipedia

Share the article and excerpts

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