Macros like $COPY_SRC$ need Inspector to fully define their parameters

  • 13
  • 41

I wonder whether anybody thinks like me that macro parameters should not be typed in Inspector window but rather in the editor ? For example currently the actual useful code being copied by $COPY_SRC$ is written in Inspector and the dummy code is written in the editor. I suggest it would be better to write them both into the editor. I think it would make it more obvious what's going on in the code. But i'm not fully sure in my point, so tell me about advantages of the current approach if there are ones.

Actually I think having them shown inline will result in unreadable generators. Once MPS supports multiple concepts per editor it might be different. Then one can switch depending on the complexity of the macro code.
Having the code which is generated shown in the inspector will result in very unreadable generators as well I think

But do you agree that it is a bit weird when to read the code it is not enough to just read it but it takes you to run cursor through the text ?

Typically I add a comment to the macro if it is somewhat complex. For me this is enough

At first it looks like disadvantage, but then you understand that it is very convenient way to present tree structure.

Please, give more details. Why exactly it is more convenient ? And i'm
really asking 'why' and not trying to argue.

Well, simply said, it is exatly what Bernd said.

In details, if you have complex node structure and you have only one projection view (main editor), you are forced to include all major features into this editor, making it unreadable in some cases, and leave simple things to intentions/actions. In templates, I think, you are focused on the structure of a template, and not on routines of macro implementation. Inspector gives you as language designer a possibility to hide complexity of node tree structure and attract your language user's focus to what you want him to focus to, in case of templates usage - template structure.

Am i right in assumption that they consider the template code as part of a documentation ? I mean - if i am the language user am i supposed to look at the template code to get understanding how to use the language ?

Well, on one hand if you suppose your language to be used by, say, your customers, you probably wont expose all generation routines as it's totally useless for clients. On another, if you extend general purpose language with your constructs, model designer (or language user) could explore your templates in case if your language lacks documentation and this user knows MPS as good as you :)

And to answer to your question below, you can always propose new features in MPS by youtrack.

I can imagine also the use case scenario in which there is a switch to show just replacement parts of macros (which are now in inspector) or show just arguments of macros (now in the editor) or show both (for example in some vertical layout - table or vertical bracket) - all of that in the editor.

I like this approach in general and have started using it in some of my languages. I use an intention to toggle between a "clean" view and a detailed view in the editor.

Thanks for sharing your experience, Bernd.

Like Mike, I use both the inspector and the toggle view. It depends on the language (and the resulting models). It took me some time to get used to the inspector, but now I won't miss it! It helps to hide the details and keep the model clear and readable.

Jens