Having a concept extend/subtype a specific class? Follow
Hello, I'm writing a DSL extending baseLanguage with MPS; I'm still new on MPS so there is some things about the type system that I don't really understand yet.
Currently, I'm stucked on this: in my language I have the concept "Agent", which extends ClassConcept and which is converted to base language "Class<? extends Agent>". Basically, I want my users to write "agent X { ... }" in the DSL and at the end (with generators) I want it to be converted in "class X extends Agent { ... }". So far, this works.
I also have an external library which provides methods which takes as parameters objects which are either of type "Agent" or of type "Class<? extends Agent>". For instance, I will talk about a method "spawn(Class<? extends Agent> agentClass)".
If I declare "class X extends Agent { ... }", later in the code I'm able to write "spawn(X.class)". But if I declare "agent X", and I call "spawn(X.class)" then I get the error "Error: X is not a subtype of Agent". And I want to find a way to suppress this error.
I guess it's something really simple related to the type system, but I did'nt find how to do it.
Thanks for any help.
Please sign in to leave a comment.
Two things:
and
Thanks a lot, it works perfectly :)