Questions tagged [polymorphism]
In computer science, polymorphism is a programming language feature that allows values of different data types to be handled in a uniform manner.
polymorphism
1,806
questions with no upvoted or accepted answers
9
votes
0
answers
286
views
Use case of kind polymorphism with AnyKind
Given
trait Int // proper type
trait List[A] // 1st-order-kinded type constructor
trait Functor[F[_]] // higher-order-kinded type constructor taking type constructor
...
9
votes
0
answers
4k
views
Proper use of polymorphism / inheritance in Open API 3
I am missing something in the proper use of polymorphism in Open API 3.
In the specification document (3.0.2), an example uses oneOf, and optionally the Discriminator block :
MyResponseType:
...
9
votes
0
answers
721
views
Which languages, if any, implement rank-2 parametric polymorphism and why not ML?
In section 23.8 of his book Types and Programming Languages, Benjamin C. Pierce writes the following:
Another well-studied restriction of System F is rank-2 polymorphism, introduced by Leivant (...
9
votes
0
answers
176
views
Representing polymorphism with unification-fd
I'd like to use the unification-fd package to implement a simple typechecker for a Hindley-Milner type system. This requires the representation of polymorphic ("forall") types.
What's the best way ...
8
votes
0
answers
111
views
How to design a base class that needs to join a thread in its destructor, which operates on the same class instance?
I just got a juicy race condition. Consider the following classes:
#include <atomic>
#include <chrono>
#include <iostream>
#include <thread>
class A
{
std::thread th;
...
7
votes
0
answers
694
views
TypeOf fails to work with Excel workbook's ActiveSheet that implements interface
I have a PublicNotCreatable interface PublicInterface
Option Explicit
Sub DoSomething()
End Sub
And in the same workbook, I have a single sheet, Sheet1, that implements PublicInterface
Option ...
7
votes
0
answers
689
views
Nested polymorphic deserialization with Jackson
I have a use case very similar to Jackson deserializing nested polymorphic type , except that I want to have two nested abstract types deserialized based on JsonTypeInfo.As.PROPERTY with different ...
7
votes
3
answers
2k
views
ActiveScaffold: How to create a drop-down select for polymorphic association?
I'm trying to create a drop-down select box for a polymorphic association with ActiveScaffold.
I have:
class Award
belongs_to :sponsorship, :polymorphic => :true
end
class Organization
...
7
votes
1
answer
186
views
Is placement new of Derived type within a vector / array of Base type legal
Is placement new of derived object within a vector / array defined to be base object legal
#include <iostream>
#include <memory>
#include <vector>
struct A
{
virtual ~A()
{
...
5
votes
0
answers
852
views
go-generics : convert list of objects implements client.Object to a list
We have the following type which is generic resource list,
the struct has 4 generic parameters (all related to the object list pointer type) but I couldn't find a way to reduce it.
import(
...
&...
5
votes
1
answer
586
views
How to infer event type using generics in polymorphic component
I have a polymorphic component in which I try to infer event type by generic. Unfortunately, typescript is screaming about incompatible types.
import React, { forwardRef } from "react";
...
5
votes
0
answers
809
views
EmbeddableId should be mapped with insert="false" update="false"
I have the following entities: Match with embeddableId MatchKey and a polymorphic entity OrganisationMatch
Hibernate is blowing up with Repeated column in mapping for entity: net.satago.web.entities....
5
votes
1
answer
291
views
Sean Parent: for polymorphic types in an inheritance hierarchy, having mutable object is the extreme exception
I am wondering what Sean Parent actually means
by this statement
for polymorphic types in an inheritance hierarchy, having mutable object is the extreme exception...
he goes on to mention two ...
5
votes
0
answers
878
views
How to code a Polymorphic Model Binder and Provider in MVC 6
This question has been asked before on SO and elsewhere in the context of MVC3 and there are bits and bobs about it related to ASP.NET Core RC1 and RC2 but niot a single example that actually shows ...
5
votes
0
answers
2k
views
C++ How to Make a Virtual Function with a Lambda Parameter Work
My intention in the following code is to be able to call a virtual function with a lambda as its parameter. The way I go about it is clearly not right, as virtual templates are not allowed.
Is there ...