Skip to content
Snippets Groups Projects
Commit d36493c0 authored by Alexander Turenko's avatar Alexander Turenko Committed by Alexander Turenko
Browse files

console: create per-session variables scope

Fixes #9985

@TarantoolBot document
Title: Interactive console now has its own per-session variables scope

It is counter-intuitive that all the non-local assignments in the
console affect globals and may interfere with application's logic.

It is also counter-intuitive that the non-local assignments are shared
between different console sessions.

Now, each console session has its own variables scope and the non-local
assignments use it instead of globals.

Let's consider examples of the new behavior.

Example 1. A console session has a variable scope that is separate from
globals.

```lua
console_1> _G.x = 1
console_1> x = 2

console_1> _G.x
---
- 1
...
console_1> x
---
- 2
...
```

Note: A global variable is still accessible using `_G` even if the same
named session scope variable exists.

Example 2. A global variable is read if there is no session local
variable.

```lua
console_1> _G.x = 1
console_1> x
---
- 1
...
```

Example 3. Different console sessions have separate variable scopes.

```lua
console_1> x = 1
console_2> x = 2

console_1> x
---
- 1
...
console_2> x
---
- 2
...
```

The new behavior is enabled using the `console_session_scope_vars`
compat option. The option is `old` by default in Tarantool 3.X, `new` by
default in 4.X. The `old` behavior is to be removed in 5.X.

Please, create the following page:
https://tarantool.io/compat/console_session_scope_vars

Please, add the new compat option into the configuration reference.
parent bb430c55
No related branches found
No related tags found
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment