This is documented, though admittedly not so clearly (mea culpa there). Some information can be found on the help page ?CodeGeneration,LanguageDefinition,Printer,LanguageAttribute.

In short, you are correct that there is a name validity test applied to the original names from Maple. If that test fails, i.e. if the original Maple names will not be valid identifiers in the target language (in this case Matlab), they are automatically replaced.

The validity test is controlled by a "language attribute" called **Name_IsValid**, a short description of which appears in a table in the above link. In the following I'll explain how you can view and change that setting.

## Viewing the Validity Test

To view the Name_IsValid attribute for CodeGeneration[Matlab]:

`> showstat( CodeGeneration:-LanguageDefinition:-Get("Matlab"):-Printer:-GetLanguageAttribute("Name_IsValid") );`

`attribtab["Name_IsValid"] := proc(x)`

1 length(x) <= 31 and StringTools:-RegMatch("^[A-Za-z][A-Za-z0-9_]*$",x)

end proc

The condition here takes the input variable name (as a string), checks that it is 31 characters or less, that it starts with a letter, and that all subsequent characters are letters, digits, or underscores. If that condition is false, that variable will be replaced.

## Changing the Validity Test

Now, on to the next part: how to change it. To use a different condition, first let's start with an example where name replacements are made now:

`> p := proc(`X.1`, `X.2`) `X.1` * `X.2` end proc);`

`p := proc(`X.1`, `X.2`) `X.1` * `X.2` end proc)`

`> CodeGeneration:-Matlab(p);`

`Warning, the following variable name replacements were made: X.1 -> cg, X.2 -> cg1`

function preturn = p(cg, cg1)

preturn = cg * cg1;

We can then define new language, an extension of Matlab, which we'll call MyMatlab. This will be like Matlab in every way but for which every identifier is valid. This can be accomplished in one line with:

`> CodeGeneration:-LanguageDefinition:-Define( "MyMatlab", extend="Matlab", SetLanguageAttribute("Name_IsValid"=true) );`

That's it; the new language is defined. The "Name_IsValid"=true part simply says "always return true from every validity check". To see MyMatlab in action on our example you can just do:

`> CodeGeneration:-Translate( p, language="MyMatlab" );`

function preturn = p(X.1, X.2)

preturn = X.1 * X.2;

If you want to use this frequently, you can of course then define:

`> MyMatlab := () -> CodeGeneration:-Translate(args, language="MyMatlab" );`

You can then use MyMatlab in much the same way as you would use CodeGeneration:-Matlab:

`> MyMatlab(p);`

function preturn = p(X.1, X.2)

preturn = X.1 * X.2;

Note though the **Name_IsValid** setting is what it is for a reason: if you change it, the identifiers you produce may not be valid for Matlab. In this case, they specifically are not.