Use `*1` instead of `_` for REPL history

`_`, as a variable, is now the shadow subtraction operator.
This commit is contained in:
Kodi Arfer 2018-03-04 14:44:56 -08:00
parent 85968e70dd
commit 3c97d2982c
3 changed files with 11 additions and 2 deletions

View File

@ -5,6 +5,10 @@ Unreleased
Other Breaking Changes
------------------------------
* `_` and `-` are now equivalent as single-character names
* The REPL history variable `_` is now `*1`
* Non-shadow unary `=`, `is`, `<`, etc. now evaluate their argument
instead of ignoring it. This change increases consistency a bit
and makes accidental unary uses easier to notice.

View File

@ -112,8 +112,8 @@ class HyREPL(code.InteractiveConsole):
if value is not None:
# Make the last non-None value available to
# the user as `_`.
self.locals['_'] = value
# the user as `*1`.
self.locals[mangle("*1")] = value
# Print the value.
try:
output = self.output_fn(value)

View File

@ -74,6 +74,11 @@ def test_bin_hy_stdin_multiline():
assert "'abcd'" in output
def test_bin_hy_history():
output, _ = run_cmd("hy", '(+ "a" "b")\n(+ *1 "y" "z")')
assert "'abyz'" in output
def test_bin_hy_stdin_comments():
_, err_empty = run_cmd("hy", '')