LionWeb-io / specification

Specifications of the LionWeb initiative
http://lionweb.io/specification/
7 stars 0 forks source link

Which parts of a link can be specialized? #8

Closed enikao closed 1 year ago

enikao commented 2 years ago

AbstractConcepts can specialize the type of a Link of all transitively extended AbstractConcepts.

Specializing cardinality

Pro:

Con:

Specializing name

Pro:

Con:

Example A: Only change type

classDiagram
Tree --> "0..*" GreenTreeThing: greenThings
<<abstract>> GreenTreeThing
Tree <|-- NeedleTree
GreenTreeThing <|-- Needle
NeedleTree --> Needle: greenThings specialized

Example B: Change type, cardinality, name

classDiagram
Tree --> "0..*" GreenTreeThing: greenThings
<<abstract>> GreenTreeThing
Tree <|-- NeedleTree
GreenTreeThing <|-- Needle
NeedleTree --> "1..*" Needle: needles specializes greenThings
slisson commented 2 years ago

We should collect use cases and try to find alternatives. From a typesystem perspective the specialized links in MPS are unsound.

enikao commented 2 years ago

@slisson Could you explain the typesystem issue with specialized links?

slisson commented 2 years ago
node<NeedleTree> needleTree = new node<NeedleTree>()
node<Tree> tree = needleTree
tree.greenThings.add(new node<GreenTreeThing>())
node<Needle> needle = needleTree.greenThings.last

The variable needle actually references a node<GreenTreeThing>, but because of the specialization the type system doesn't show an error. A sound type system has to prevent write access to Tree.greenThing which means specialization can only be allowed if Tree.greenThing knows that it can be specialized. In Java this would be done with generics and the java type system does prevent write access in such cases.

enikao commented 2 years ago

Thanks for the example.

Possible solution: Assuming DerivedFeatures are read-only, we could allow only them to be specialized. (DerivedFeature would not be that great of a name then, though.)

markusvoelter commented 2 years ago

I would suggest to not have specialized Links and handle it -- as you suggest, @enikao -- through derived features, if at all. And yes, derived features are always readonly.

dslmeinte commented 2 years ago

I agree to not have Link specializations at all. We pretty soon venture into territory that should be covered by an actual type system and constraints defined on top of a particular metamodel.

ftomassetti commented 1 year ago

+1 for not having specialized links

markusvoelter commented 1 year ago

Decision: No structural specialisation (of links and stuff) because