Skip to content

SI-6502 Repl reset/replay take settings args#3986

Merged
gkossakowski merged 2 commits intoscala:2.11.xfrom
som-snytt:issue/6502-no-cp
Oct 7, 2014
Merged

SI-6502 Repl reset/replay take settings args#3986
gkossakowski merged 2 commits intoscala:2.11.xfrom
som-snytt:issue/6502-no-cp

Conversation

@som-snytt
Copy link
Contributor

The reset and replay commands take arbitrary command line args.
When settings args are supplied, the compiler is recreated.

For uniformity, the settings command performs only the usual
arg parsing: use -flag:true or -flag instead of +flag, and clearing a
setting is promoted to the command line, so that -Xlint: is not
an error but clears the flags.

scala> maqicode.Test main null
<console>:8: error: not found: value maqicode
              maqicode.Test main null
              ^

scala> :reset -classpath/a target/scala-2.11/sample_2.11-1.0.jar
Resetting interpreter state.
Forgetting all expression results and named terms: $intp

scala> maqicode.Test main null
Hello, world.

scala> val i = 42
i: Int = 42

scala> s"$i is the loneliest numbah."
res1: String = 42 is the loneliest numbah.

scala> :replay -classpath ""
Replaying: maqicode.Test main null
Hello, world.

Replaying: val i = 42
i: Int = 42

Replaying: s"$i is the loneliest numbah."
res1: String = 42 is the loneliest numbah.

scala> :replay -classpath/a ""
Replaying: maqicode.Test main null
<console>:8: error: not found: value maqicode
              maqicode.Test main null
              ^

Replaying: val i = 42
i: Int = 42

Replaying: s"$i is the loneliest numbah."
res1: String = 42 is the loneliest numbah.

Clearing a clearable setting:

scala> :reset -Xlint:missing-interpolator
Resetting interpreter state.

scala> { val i = 42 ; "$i is the loneliest numbah." }
<console>:8: warning: possible missing interpolator: detected interpolated identifier `$i`
              { val i = 42 ; "$i is the loneliest numbah." }
                             ^
res0: String = $i is the loneliest numbah.

scala> :reset -Xlint:
Resetting interpreter state.
Forgetting this session history:

{ val i = 42 ; "$i is the loneliest numbah." }

scala> { val i = 42 ; "$i is the loneliest numbah." }
res0: String = $i is the loneliest numbah.

scala> :replay -Xlint:missing-interpolator
Replaying: { val i = 42 ; "$i is the loneliest numbah." }
<console>:8: warning: possible missing interpolator: detected interpolated identifier `$i`
              { val i = 42 ; "$i is the loneliest numbah." }
                             ^
res0: String = $i is the loneliest numbah.

Review by @gkossakowski

@som-snytt
Copy link
Contributor Author

PLS REBUILD/pr-scala@13e9317

@scala-jenkins
Copy link

(kitty-note-to-self: ignore 55755093)
🐱 Roger! Rebuilding pr-scala for 13e9317. 🚨

Copy link
Contributor Author

Choose a reason for hiding this comment

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

doesn't reflect arbitrary settings.

People expect to change the class path midstream.

Let's disabuse them by removing the broken command.

The internals are deprecated.
The reset and replay commands take arbitrary command line args.
When settings args are supplied, the compiler is recreated.

For uniformity, the settings command performs only the usual
arg parsing: use -flag:true instead of +flag, and clearing a
setting is promoted to the command line, so that -Xlint: is not
an error but clears the flags.

```
scala> maqicode.Test main null
<console>:8: error: not found: value maqicode
              maqicode.Test main null
              ^

scala> :reset -classpath/a target/scala-2.11/sample_2.11-1.0.jar
Resetting interpreter state.
Forgetting all expression results and named terms: $intp

scala> maqicode.Test main null
Hello, world.

scala> val i = 42
i: Int = 42

scala> s"$i is the loneliest numbah."
res1: String = 42 is the loneliest numbah.

scala> :replay -classpath ""
Replaying: maqicode.Test main null
Hello, world.

Replaying: val i = 42
i: Int = 42

Replaying: s"$i is the loneliest numbah."
res1: String = 42 is the loneliest numbah.

scala> :replay -classpath/a ""
Replaying: maqicode.Test main null
<console>:8: error: not found: value maqicode
              maqicode.Test main null
              ^

Replaying: val i = 42
i: Int = 42

Replaying: s"$i is the loneliest numbah."
res1: String = 42 is the loneliest numbah.
```

Clearing a clearable setting:
```
scala> :reset -Xlint:missing-interpolator
Resetting interpreter state.

scala> { val i = 42 ; "$i is the loneliest numbah." }
<console>:8: warning: possible missing interpolator: detected interpolated identifier `$i`
              { val i = 42 ; "$i is the loneliest numbah." }
                             ^
res0: String = $i is the loneliest numbah.

scala> :reset -Xlint:
Resetting interpreter state.
Forgetting this session history:

{ val i = 42 ; "$i is the loneliest numbah." }

scala> { val i = 42 ; "$i is the loneliest numbah." }
res0: String = $i is the loneliest numbah.

```
@som-snytt
Copy link
Contributor Author

Rebased and corrected :help.

@som-snytt
Copy link
Contributor Author

PLS REBUILD/pr-scala@e720bab

@scala-jenkins
Copy link

(kitty-note-to-self: ignore 56975950)
🐱 Roger! Rebuilding pr-scala for e720bab. 🚨

@adriaanm
Copy link
Contributor

adriaanm commented Oct 7, 2014

ping @gkossakowski

@gkossakowski
Copy link
Contributor

LGTM

@gkossakowski gkossakowski self-assigned this Oct 7, 2014
@gkossakowski
Copy link
Contributor

Excellent work!

gkossakowski added a commit that referenced this pull request Oct 7, 2014
 SI-6502 Repl reset/replay take settings args
@gkossakowski gkossakowski merged commit 47ab999 into scala:2.11.x Oct 7, 2014
heathermiller added a commit to heathermiller/scala that referenced this pull request Oct 14, 2014
….10)

Fixes SI-6502, reenables loading jars into the running REPL
(regression in 2.10). This PR allows adding a jar to the compile
and runtime classpaths without resetting the REPL state (crucial
for Spark SPARK-3257).

This follows the lead taken by @som-snytt in PR scala#3986, which
differentiates two jar-loading behaviors (muddled by cp):

  - adding jars and replaying REPL expressions (using replay)
  - adding jars without resetting the REPL (deprecated cp,
    introduced require) This PR implements require (left
    unimplemented in scala#3986)

This PR is a simplification of a similar approach taken by
@gkossakowski in scala#3884. In this attempt, we check first to make
sure that a jar is only added if it only contains new
classes/traits/objects, otherwise we emit an error. This differs
from the old invalidation approach which also tracked deleted
classpath entries.
heathermiller added a commit to heathermiller/scala that referenced this pull request Nov 5, 2014
….10)

Fixes SI-6502, reenables loading jars into the running REPL
(regression in 2.10). This PR allows adding a jar to the compile
and runtime classpaths without resetting the REPL state (crucial
for Spark SPARK-3257).

This follows the lead taken by @som-snytt in PR scala#3986, which
differentiates two jar-loading behaviors (muddled by cp):

  - adding jars and replaying REPL expressions (using replay)
  - adding jars without resetting the REPL (deprecated cp,
    introduced require) This PR implements require (left
    unimplemented in scala#3986)

This PR is a simplification of a similar approach taken by
@gkossakowski in scala#3884. In this attempt, we check first to make
sure that a jar is only added if it only contains new
classes/traits/objects, otherwise we emit an error. This differs
from the old invalidation approach which also tracked deleted
classpath entries.
heathermiller added a commit to heathermiller/scala that referenced this pull request Nov 5, 2014
….10)

Fixes SI-6502, reenables loading jars into the running REPL
(regression in 2.10). This PR allows adding a jar to the compile
and runtime classpaths without resetting the REPL state (crucial
for Spark SPARK-3257).

This follows the lead taken by @som-snytt in PR scala#3986, which
differentiates two jar-loading behaviors (muddled by cp):

  - adding jars and replaying REPL expressions (using replay)
  - adding jars without resetting the REPL (deprecated cp,
    introduced require) This PR implements require (left
    unimplemented in scala#3986)

This PR is a simplification of a similar approach taken by
@gkossakowski in scala#3884. In this attempt, we check first to make
sure that a jar is only added if it only contains new
classes/traits/objects, otherwise we emit an error. This differs
from the old invalidation approach which also tracked deleted
classpath entries.
@som-snytt som-snytt deleted the issue/6502-no-cp branch February 9, 2015 01:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants