Zulip Chat Archive

Stream: mathlib4

Topic: continue long interpolated string on new line


Thomas Murrills (May 08 2023 at 22:34):

Style question: is there a better way to write a long error message than

throwError m!"looooooooooooooong message"
  ++ m!"continuing loooooooooooong message"
  ++ m!"etc"

I noticed that newlines are retained in the resulting error message, and I'd rather not do not.

Eric Wieser (May 08 2023 at 22:39):

@Mario Carneiro's hack here was

throwError m!"looooooooooooooong message {
  }continuing loooooooooooong message{
  }etc"

I think

Eric Wieser (May 08 2023 at 22:39):

Which puts the newlines into interpolation commands that get ignored

Eric Wieser (May 08 2023 at 22:39):

I might have butchered the details

Thomas Murrills (May 08 2023 at 22:45):

Oh that's a nice hack! I see, looks like it needs to have a term in there:

throwError m!"looooooooooooooong message {
  ""}continuing loooooooooooong message{
  ""}etc"

Thomas Murrills (May 08 2023 at 22:45):

But at that point, I wonder if ++ m! is prettier :sweat_smile:

Mario Carneiro (May 09 2023 at 01:50):

++ m! isn't always available if it is expecting an interpolated string. i.e. you didn't need to use m! because throwError is a macro that adds this itself


Last updated: Dec 20 2023 at 11:08 UTC