Interactive console now has its own per-session variables scope
Nobody has claimed this yet.
- Dominant language
- CSS
- Stars
- 15
- Forks
- 49
- Avg merge
- 1d 13h
- Merged PRs (30d)
- 3
Description
Related dev. issue(s): https://github.com/tarantool/tarantool/issues/9985
Related doc. issue(s): https://github.com/tarantool/doc/issues/4196
Product: Tarantool
Since: 3.2
Root document:
- https://tarantool.io/compat/console_session_scope_vars
- https://www.tarantool.io/en/doc/latest/reference/reference_lua/console/
SME: @ Totktonada
Details
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.
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.
console_1> _G.x = 1
console_1> x
---
- 1
...
Example 3. Different console sessions have separate variable scopes.
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.
Requested by @ Totktonada in https://github.com/tarantool/tarantool/commit/d36493c06b8b9ebcfde5cca6a15937de227c5af1 (https://github.com/tarantool/tarantool/pull/10001, https://github.com/tarantool/tarantool/issues/9985).
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the console reference at https://www.tarantool.io/en/doc/latest/reference/reference_lua/console/ and the related compatibility issue at https://tarantool.io/compat/console_session_scope_vars. Create the compatibility page with the described per-session scope behavior and add the console_session_scope_vars option to the configuration reference; the work is done when both documentation requests are covered.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- lua
- Domain
- documentation
- Issue type
- Documentation
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100