Template arguments not working correctly

I'm trying to convert a math expression into a sequence of static Math calls. Said expression can reference two variables, so the template switch I'm using takes two parameters and passes them to each subsequent invocation.

The problem is that it doesn't seem to understand it's supposed to be referencing local variables, because it errors out on trying to build the language with QueriesGenerated looking like this.

Am I doing this wrong, or is this a bug? 

1
3 comments

It doesn't look wrong, and it's quite puzzling provided MPS itself does the same in its templates. I wonder if you use interpreted or compiled templates (in case you didn't set 'compiled' explicitly, then it's 'interpreted') and what's the concept of 'tick' and 'particle' arguments in $SWITCH$ call. You can also try to use full notation for arguments, i.e. genContext.particle and genContext.tick to see if it helps.

0

If I change the template arguments in the switch to genContext fields, I get the exact same result as before only QueriesGenerated gets a ton of new errored methods.

The original twelve errored methods still exist though.

I don't know how to set compiled templates.

0

Hm, this is quite unexpected. There's one more possible workaround, use 'query' to pass arguments (you can find it in a completion menu for an argument). It looks cumbersome indeed but shall work.

However, the issue is very intriguing and I'd appreciate if you help to locate the cause. I believe you've got MPS sources, try to navigate e.g. to `reduce_If` template from lang.generator's generator module (out of project scope, press Cmd/Ctrl-N twice to get that in scope). Down there go to `switch_Consequence` call which I feel uses arguments exactly the same as your code. This is a template that actually works in MPS. Please check if there's any difference with your code, I'm particularly interested in the concept of arguments (right click on tick argument and Go to->ConceptDeclaration or Cmd/Ctrl-Shift-S). It has to be TemplateArgumentParameterExpression. 

0

Please sign in to leave a comment.