object StackUserProtocol extends ProtocolLang with App {
in(“State1”) goto “State2”
…
end()
}
ProtocolLang is a class with the “in”, “goto” and “end” methods.
Is there a way I can get the name “StackUserProtocol” from inside ProtocolLang?
Hi, sorry, I don’t think I explained my question very well. I meant can I get the name without knowing the name of the object in advance?
How this code would actually be used:
The user would write the StackUserProtocol object themselves and then during compilation, the ProtocolLang class should get the name of the object.
I don’t know if that is possible since the only way that ProtocolLang knows about the object is that it is extending it.
Then Bar has access to (the mangled version of) implementationName. Be aware that unmangling is not generally possible, especially if there are $ characters as part of the objects own name or its enclosing class.
Amazing! I didn’t think there would be such a simple way of doing this.
martijnhoekstra, I tried your technique and it seems to work even if I add many $ to the object name (??). So “$$Stack$UserProtocol$” worked fine. Are there other potential problems with this method?