Follow-up from the [previous](https://topanswers.xyz/tex?q=3471) expl3 question for the specific case of `msg` variables.

Usually mixing global and local assignments to variables in expl3 is discouraged. Furthermore, normally it is assumed that a variable is either *local* or *global* (or *constant*), as indicated by its name prefix, either `l_` or `g_` (or `c_`), a term that actually indicates the allowed types of assignments for the variable (local-only for `l_`, global-only for `g_`, no assignments for `c_`).

However, `msg` variables seem to be a kind of special case, as the variable name doesn't seem to be exposed to the programmer, so there doesn't seem to be a way to find out whether a `msg` variable is `l_` or `g_` (or `c_`).

The interface3.pdf manual documents the `\msg_set:nnn`, `\msg_set:nnnn`, `\msg_gset:nnn`, `\msg_gset:nnnn` functions, but doesn't say which one (global or local) is it better to use.

TBH, I don't see a particular reason to ever assign to a `msg` variable (as opposed to creating the message with `\msg_new:nnn`), but nonetheless I ask the question for completeness: when to use local, and when global assignment to messages? Which one should be preferred if the choice otherwise doesn't matter?
Top Answer
Joseph Wright
Messages use a single namespace: the same is true for e.g. colours and keys. These are always local assignments. So I woudl favour `\msg_set:nn(nn)` over `\msg_gset:nn(nn)`.

The code in `l3msg` was written a while ago, and it would be sensible for us to tidy this up a bit. I will raise this with the team: with hindsight, we should probably deprecate `\msg_new:nn(nn)` in favour of `\msg_set:nn(nn)` in the same way colours work.

Enter question or answer id or url (and optionally further answer ids/urls from the same question) from

Separate each id/url with a space. No need to list your own answers; they will be imported automatically.