Scope of @time

Is the scope of @time supposed to be local?

If I do the following:

x = 1
@time x = 2

Then the value of x will be 2. Why can I modify the value of a global variable x in a local scope @time?

Similarly, I can declare variables under @time and access them outside @time. For example,

@time v = 3
Then the value of v will be 3. Why can I access the local variable v?

In contrast, I can’t do the above in @profile.

Thank you.

Macros can do whatever they want (well, not quite). So, they can choose to introduce a new scope or not. You can have a look to what @time expands to with @macroexpand @time x=1. There is no scope-defining block defined, thus no new scope is made. This contrasts to @profile which uses a try-finally block which does introduce a new scope.