Closed enikao closed 1 year ago
We should collect use cases and try to find alternatives. From a typesystem perspective the specialized links in MPS are unsound.
@slisson Could you explain the typesystem issue with specialized links?
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.
Thanks for the example.
Possible solution: Assuming DerivedFeature
s are read-only, we could allow only them to be specialized.
(DerivedFeature
would not be that great of a name then, though.)
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.
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.
+1 for not having specialized links
Decision: No structural specialisation (of links and stuff) because
AbstractConcept
s can specialize thetype
of aLink
of all transitively extendedAbstractConcept
s.Specializing cardinality
Pro:
Con:
Specializing name
Pro:
Con:
NeedleTree
defines methodgetNeedles
and inheritsgetGreenTreeThings
)Example A: Only change type
Example B: Change type, cardinality, name