Is it possible to parametrize concept with another concept (generic concept)?
Hello!
I'm looking an ability to specify a generic parameter to a concept.
I'm implementing some YAML-based DSL. YAML allows to include any part of its content from the separate file and I'd like to implement this in MPS editor as well.
Here is my sample.
Root concept has a child "documentation". It's target may be either inline documentation or included documentation. Inline documentation has a body, included documentation has a reference to a documentation file. Documentation file is also root concept, that has documentation body as its child.
I'd like to parametrize concepts Inline, Include and File with DocumentationBody to reuse for another root's child.
Is it possible?
Thanks, Alexey
I'm looking an ability to specify a generic parameter to a concept.
I'm implementing some YAML-based DSL. YAML allows to include any part of its content from the separate file and I'd like to implement this in MPS editor as well.
Here is my sample.
Root concept has a child "documentation". It's target may be either inline documentation or included documentation. Inline documentation has a body, included documentation has a reference to a documentation file. Documentation file is also root concept, that has documentation body as its child.
I'd like to parametrize concepts Inline, Include and File with DocumentationBody to reuse for another root's child.
Is it possible?
Thanks, Alexey
Please sign in to leave a comment.
Am I right you are asking about "how to force creating a specific child (DocumentationBody) when an instance of its parent is created in editor (Inline, Include, File)"?
In this case, the answer is "yes", the right way to do this is NodeFactories in Editor aspect of a language.
What I want to create is:
concept File<T> implements INamedConcept
File has one child:
File has an editor like this:
Then I'd like to create DocReference concept with reference ref: File<DocumentBody> and create instances (somehow) of File<DocumentBody> in my solution.
While writing this description I've found a possible solution. I'll add a reference to File called "type" with target ConceptDeclaration. I'm not sure, that it is a "good solution"...
We don't have "generic parameters" in concepts as it's not clear where they should be taken into account, instead, you specify the precise behavior you want to get in the corresponding aspect.
Hi,
I also find myself needing generic concepts. Something like
My main motivation is code reuse and extensibility. I want to allow extensions of my language to reuse my `List` concept with their own element types.
I don't see how to adapt @apomelov's solution, since `List`'s type parameter may be instantiated not only to a concrete type, but also to a type argument of the containing concept:
> We don't have "generic parameters" in concepts as it's not clear where they should be taken into account
I admit I don't understand what the problem with generic concepts would be.