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

Enable -howtorun:repl -i -e #5872

Merged
merged 1 commit into from May 10, 2017
Merged

Enable -howtorun:repl -i -e #5872

merged 1 commit into from May 10, 2017

Conversation

som-snytt
Copy link
Contributor

@som-snytt som-snytt commented Apr 28, 2017

The runner concatenates -i files and -e expression
to run the code as a script. The addition of -I
broke detection of -i there, which is now fixed.

In addition, allow explicit -howtorun:repl which
is now useful for -e, so that REPL will handle
-i and -I and then evalute the expression as
usual (and as the -help text implies).

Fixes: scala/bug#10284

Where dbl.sc defines overloaded f (or redefines it if not pasted):

$ skala -howtorun:repl -nc -I dbl.sc -e "println(f(42))"
<console>:13: error: type mismatch;
 found   : Int(42)
 required: String
       println(f(42))
                 ^

$ skala -howtorun:repl -nc -i dbl.sc -e "println(f(42))"
int 42

$ skala -howtorun:repl -nc -i dbl.sc -e "f(42)"
res0: String = int 42

$ skala -howtorun:script -nc -i dbl.sc -e "f(42)"


I restored REPL output in REPL mode by default, as a use case.

@@ -46,6 +46,13 @@ object InteractiveReader {
}

def apply(): InteractiveReader = SimpleReader()

// a non-interactive SimpleReader that returns the given text
def apply(text: String): InteractiveReader = SimpleReader(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we move this to SimpleReader, as method fromString or constant or somesuch?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe. apply gives you a SimpleReader for some reason. apply(text) gives you the same thing, but it only reads from that input. As a user, I don't care that it's a SimpleReader. WDYT? If I were closer to the city, I'd buy you a beer to discuss.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The owing of beers is all mine! I'm probably overthinking it. By the way, I've just started work on reorganizing the repl codebase to simplify maintenance and stealing of features from ammonite. My goal for the month is some more separation of concerns. Will open a ticket to discuss once I get a sense of the concrete direction I'm headed.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I expected a clean break from spark support at some point. Also, Ammonite is asking for community funding. What a great idea. I mean dollars, not just beer support.

The runner concatenates -i files and -e expression
to run the code as a script. The addition of -I
broke detection of -i there, which is now fixed.

In addition, allow explicit `-howtorun:repl` which
is now useful for `-e`, so that REPL will handle
`-i` and `-I` and then evalute the expression as
usual (and as the `-help` text implies).

Fixes: scala/bug#10284
@som-snytt
Copy link
Contributor Author

I acceded to Adriaan's wishes for future Adriaanite REPL.

It took me forever to write a stupid test, similar to an early test I contributed when fixing scala -i for scala/bug#7805.

ReplTest was dropping two lines of output for the welcome banner, except there is no welcome banner for -e. Part of the reason it took me a while to see it, is that both settings and the output capture for testing in ILoop are complicated. Turning up debug doesn't display unmangled test transcript.

I need that beer now.

@@ -43,6 +43,13 @@ object SimpleReader {

def apply(in: BufferedReader = defaultIn, out: JPrintWriter = defaultOut, interactive: Boolean = true): SimpleReader =
new SimpleReader(in, out, interactive)

// a non-interactive SimpleReader that returns the given text
def apply(text: String): SimpleReader = apply(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cheers!

@adriaanm adriaanm merged commit 906abd0 into scala:2.12.x May 10, 2017
} else {
lines drop header.lines.size
}) map normalize
clean.map(normalize)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Previously seen at 6d8c565

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