NB: I know one suboptimal solution to this problem, which I give at the end. I'm looking for a better one. Also, I was not able to solve this problem with the solutions give in Backquote in string template?.

For example, this assignment is no problem:

example::message = "foo`bar is set to `1`"; (* no problem *)

But if one uses this message in a Message expression, then two messages appear, and the second one is malformed:

foo`bar = 3;
Message[example::message, foo`bar]
StringForm::sfq: Unmatched backquote in foo`bar is set to `1`. >>
example::message: foo`bar is set to `1`

One solution is to make a slot for the backquote, and include "`" among the message parameters:

example::message = "foo`1`bar is set to `2`";
Message[example::message, "`", foo`bar]
example::message: foo`bar is set to 3

This solution, however, is suboptimal, because it requires users to remember to include the otherwise meaningless "`" among the message parameters.


1 Answer 1


From the StringForm docs use "`.`":

m::a = "`1` `.` `2`";
Message[m::a, "a", "b"]

m::a: a ` b
  • $\begingroup$ wonder why StringTemplate doesn't use this convention. $\endgroup$
    – george2079
    Mar 14, 2017 at 22:05
  • $\begingroup$ @george2079 Message uses StringForm which is just a formatting head. But it's a much more restricted system. In StringTemplate you could match that "." to "." in your template driver so it introduces ambiguity. $\endgroup$
    – b3m2a1
    Mar 14, 2017 at 22:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.