Type variance
Relationship between a generic type or a function and a component type on subtyping
In computer programming, type variance is the relationship between subtypes of a composite type (e.g. List[Int]) and the subtypes of its components (e.g. Int). A language's chosen variance determines the relationship between, for example, a list of Cats and a list of Animals, or a function returning Cat and a function returning Animal.
Nº Q362031 ★
Comum · Saberes
Type variance
Relationship between a generic type or a function and a component type on subtyping
In computer programming, type variance is the relationship between subtypes of a composite type (e.g. List[Int]) and the subtypes of its components (e.g. Int). A language's chosen variance determines the relationship between, for example, a list of Cats and a list of Animals, or a function returning Cat and a function returning Animal.
Último preço
—
Preço mínimo
—
Mediana 7 d
—
Vendas 30 d
0
Faixa 30 d
—
Em circulação
0
Cotação
mediana
mín – máx
vendas
Sem vendas no período
Ver tabela
| Data | mediana | Mín | Máx | vendas |
|---|
Histórico de vendas
- Última venda
- —
- Média 30 d
- —
- Mínima 30 d
- —
- Máxima 30 d
- —
- Vendas 7 d
- 0
- Vendas 30 d
- 0
Ainda sem vendas.
Vendas anônimas: sem comprador nem vendedor. Os números contam só vendas entre jogadores.
Na Wikipédia
Texto em inglês Ainda não há artigo no seu idioma: trecho em inglês.
In computer programming, type variance is the relationship between subtypes of a composite type (e.g. List[Int]) and the subtypes of its components (e.g. Int). A language's chosen variance determines the relationship between, for example, a list of Cats and a list of Animals, or a function returning Cat and a function returning Animal. If the type Cat is a subtype of Animal, then an expression of type Cat should be substitutable wherever an expression of type Animal is used. Depending on the variance of the type constructor, the subtyping relation of the simple types may be either preserved, reversed, or ignored for the respective complex types. In many programming languages, for example, "list of Cat" will be a subtype of "list of Animal", because the list type constructor is covariant. This means that the subtyping relation of the simple types is preserved for the complex types. On the other hand, "function from Animal to String" is a subtype of "function from Cat to String" because the function type constructor is contravariant in the parameter type. Here, the subtyping relation of the simple types is reversed for the complex types. A programming language designer will consider variance when devising typing rules for language features such as arrays, inheritance, and generic datatypes. By making type constructors covariant or contravariant instead of invariant, more programs will be accepted as well-typed. On the other hand, programmers often find contravariance unintuitive, and accurately tracking variance to avoid runtime type errors can lead to complex typing rules. In order to keep the type system simple and allow useful programs, a language may treat a type constructor as invariant even if it would be safe to consider it variant, or treat it as covariant even though that could violate type safety.
Texto: Wikipédia em inglês, CC BY-SA 4.0. ·
Cartas próximas
-
v
variance
Variance is a measure of dispersion, meaning it is a measure of how far a set of numbers is spread out from their average value
Nº Q120504804 ★★★
Sem ofertas
-
É
É-um
Relação de subsunção entre abstrações
Nº Q1101080 ★
Sem ofertas
-
Polimorfismo (ciência da computação)
Nº Q3240252 ★★★
Sem ofertas
-
V
Variety (cybernetics)
Number of states of a cybernetic system
Nº Q1729295 ★★
Sem ofertas
-
d
derivada funcional
Concept in calculus of variation
Nº Q2621220 ★
Sem ofertas
-
Tipo de dado
Nº Q190087 ★★
Sem ofertas