Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Accessing last result in REPL should work for one parameter argument #8145

Open
scabug opened this issue Jan 13, 2014 · 4 comments
Open

Accessing last result in REPL should work for one parameter argument #8145

scabug opened this issue Jan 13, 2014 · 4 comments

Comments

@scabug
Copy link

scabug commented Jan 13, 2014

Look at the following example:

scala> 5
res0: Int = 5

scala> .*2
<console>:1: error: ';' expected but integer literal found.
       res0.*2
             ^

scala> 5
res7: Int = 5

scala> .*(2)
res8: Int = 10

The problem is that the argument in the first case is not surrounded with parentheses.

A nice improvement would be that the REPL looks if the inserted expression is in operator notation (as it is the case for .*2, it contains only one argument). If this is the case, the REPL could replace the . with the previous result to get the real operator notation res0*2 instead of concatenating it, which results in the wrong res0.*2.

If it turns out that this rule is ambigous in a more complex expression, another option would be to introduce another character for this case, for example a ,.

@scabug
Copy link
Author

scabug commented Jan 13, 2014

Imported From: https://issues.scala-lang.org/browse/SI-8145?orig=1
Reporter: @sschaef
Affected Versions: 2.11.0
See #1945

@scabug
Copy link
Author

scabug commented Apr 25, 2015

@som-snytt said:
The linked issue is about "split line healing", but the proposed solution suffers from re-evaluation of the previous line. If the previous result is inserted into the line instead, then it would be acceptable and cover this case.

Unless there is an {code}object * { def 2 = 2 }{code}. No, you'd still need to backquote the call.

@scabug
Copy link
Author

scabug commented Jun 7, 2015

@som-snytt said:
Or more likely, a dollar notation. $? * 2

@scabug
Copy link
Author

scabug commented Jan 15, 2017

@som-snytt said:
Also consider leading tab-completion to mean continue from the previous line.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants