Questions tagged [subtype]
198 questions
3
votes
1 answer
Hiding a field for a subtype in Alloy
Suppose I have the following signature declarations, in Alloy 4.2:
sig Target {}
abstract sig A {
parent: lone A,
r: some Target
}
sig B extends A {}
sig C extends A {}
When running, the resulting instances would have arrows from every B…
![](../../users/profiles/2088822.webp)
afsantos
- 5,018
- 4
- 29
- 53
3
votes
1 answer
Subtyping and Module Inclusion in OCaml
Suppose I have the following setup
module type FOO = sig type f val do_foo : f end
module type BAR = sig type b val do_bar : b end
module type FOOANDBAR =
sig
include FOO
include BAR
end
Now I want to (in a nice way, aka, without…
![](../../users/profiles/510637.webp)
Joseph Victor
- 739
- 4
- 16
3
votes
2 answers
JPA multiple discriminator values
We're setting up a new project and decided to use eclipselink for JPA. When creating our domain model we ran into a problem.
We have a base class called organisation. We also have Supplier and Customer which both extend organisation. When JPA…
![](../../users/profiles/755949.webp)
Rob
- 2,226
- 1
- 17
- 39
2
votes
2 answers
SQL Design, Joining Types and Subtypes
I'm making a traffic logging front end which allows displaying information on a specific vehicle on property as well as searching for a specific vehicle, but am unsure of the best way to proceed with my database design. What I want to do is be able…
![](../../users/profiles/1212806.webp)
maxx233
- 108
- 8
2
votes
2 answers
Scala related trait, abstract types
I have 2 related traits. Dao will be used be a class and DaoHelper will be used by Dao's companion object. I would like trait Dao to be able use functions defined in DaoHelper, the only way I could figure out how to do this is to define the…
![](../../users/profiles/454607.webp)
gobagoo
- 23
- 4
2
votes
7 answers
When should or shouldn't I use a more general variable type for referencing my object?
There are 2 classes A and B, B extends A. What is the difference between
A a = new B();
and
B b = new B()?
Both create the object of class B. What is the difference?
![](../../users/profiles/891206.webp)
Noufi
- 21
- 2
2
votes
0 answers
Python mypy: float and int are incompatible types with numbers.Real
I am new to Python's static typing module mypy. I am trying to append ints and floats to an array, which I typed statically to be Real. But mypy says that they are incompatible types with Real. I thought ints and floats are a subtype of Real?
…
![](../../users/profiles/12944664.webp)
Song Yang
- 63
- 5
2
votes
4 answers
How to prevent entering value in table when primary is used on other table?
I have to construct and populate a supertype-subtype relationship, but I cannot get it to work the way it is supposed to be. Basically PERSON table is the supertype of table STUDENT and TEACHER(subtypes). But a person can be either a student or a…
![](../../users/profiles/7837264.webp)
Loizos Vasileiou
- 511
- 2
- 20
2
votes
2 answers
How to make python typing recognize subclasses as valid types when it expects their parent class?
Here is a minimal example of what I need to do:
from typing import Callable, Any
class Data:
pass
class SpecificData(Data):
pass
class Event:
pass
class SpecificEvent(Event):
pass
def detect_specific_event(data:…
![](../../users/profiles/6764739.webp)
Petar Chernev
- 63
- 5
2
votes
2 answers
In ada programming language, Is there a way to create a subtype which takes differently positioned enums of a type?
I am trying create a subtype which takes certain enumerations of a type for example,
type Integers_Type is (1,2,3,4,5,6,7,8,9,10);
I want something like this,
subtype Odd_Numbers_Type is Integers_Type (1,3,5,7,9);
I understand that when we use the…
![](../../users/profiles/9695244.webp)
S.Abishek
- 23
- 3
2
votes
4 answers
Java generics with parameter - inheritance
I have the following code:
public class Inheritance {
class A{
}
class B extends A{
}
}
Could somebody explain me, how it actually works? Does the Class B extend only A class, which parameters are…
![](../../users/profiles/10708897.webp)
coolchock
- 89
- 4
2
votes
1 answer
kotlin override property from interface with subtype
I have the following situation:
interface AbstractState {...}
interface SubState {...}
interface NiceInterface {
var currentState: AbstractState
...
}
Furthermore I have a class which implements this interface.
class Class : NiceInterface {
…
![](../../users/profiles/4336990.webp)
Punika
- 275
- 3
- 14
2
votes
4 answers
Ada Source code modifications using ASIS(Ada Semantics interface specifications)
i am developing a tool for finding sub type range overflow problems in Ada source code.for this purpose i am using ASIS for finding assignment statements in Ada source code and finding type of the variables on the right side of the assignment…
![](../../users/profiles/2203789.webp)
Lakshman Naik
- 45
- 6
2
votes
1 answer
What is the favored alternative to subtyping that library writers choose, and why?
I have two types, A and B, which share a common interface T. I want to write functions which work with both A and B through the interface T.
In C++, I would have T be an abstract superclass of both A and B, and write functions accepting a parameter…
![](../../users/profiles/1473169.webp)
yawn
- 263
- 1
- 3
- 15
2
votes
1 answer
Coq: Bypassing the uniform inheritance condition
I've trouble understanding the (point of the) gauntlet one has to pass to bypass the uniform inheritance condition (UIC). Per the instruction
Let /.../ f: forall (x₁:T₁)..(xₖ:Tₖ)(y:C u₁..uₙ), D v₁..vₘ be a
function which does not verify the…
![](../../users/profiles/4967226.webp)
jaam
- 802
- 4
- 18