Use *1
instead of _
for REPL history
`_`, as a variable, is now the shadow subtraction operator.
This commit is contained in:
parent
85968e70dd
commit
3c97d2982c
4
NEWS.rst
4
NEWS.rst
@ -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.
|
||||
|
@ -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)
|
||||
|
@ -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", '')
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user