You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
`:load` can only interpret a file from top to bottom which is for example a problem when there is a reference to a definition that is defined later. `:paste` is overworked to solve this limitation. It now can not only load a file but also handle it as a single unit.
46
+
47
+
Contents of file `test.scala`:
48
+
```scala
49
+
// Foo has a companion object
50
+
classFoo { privatevalfoo=7 }
51
+
objectFoo { defapply(f: Foo) = f.foo }
52
+
Foo(newFoo)
53
+
```
54
+
55
+
REPL session:
56
+
```scala
57
+
scala>:paste test.scala
58
+
Pasting file y.scala...
59
+
defined classFoo
60
+
defined objectFoo
61
+
res4:Int=7
62
+
```
63
+
64
+
Theres is also the `-raw` option available, which denotes that the following is not a script anymore, but a normal Scala file:
65
+
66
+
```scala
67
+
scala>:paste -raw
68
+
// Entering paste mode (ctrl-D to finish)
69
+
70
+
packageabc
71
+
caseclassFoo(bar: Int)
72
+
73
+
// Exiting paste mode, now interpreting.
74
+
75
+
76
+
scala> abc.Foo(5)
77
+
res5: abc.Foo=Foo(5)
78
+
```
79
+
80
+
Furthermore, there is a bug fixed that led to the problem that no error message is reported when the read code was incomplete ([#2672](https://github.com/scala/scala/pull/2672)).
Sometimes one get warnings from the compiler about some code snippets. Previously it was needed to switch to `:power` mode in order to enable a full output of the warnings. Changing some other variables required a switch to the `:power` mode too. With this release it is possible to do this directly with the `:settings` command. By prefixing an property with a `+` sign the setting is enabled, an `-` disables it:
117
+
118
+
```scala
119
+
scala>newBigInt(java.math.BigInteger.TEN)
120
+
res16: scala.math.BigInt=10
121
+
122
+
scala>newBigInt(java.math.BigInteger.TEN) {}
123
+
warning: there were 1 deprecation warning(s); re-run with-deprecation for details
124
+
res17:BigInt=10
125
+
126
+
scala>:settings +deprecation
127
+
128
+
scala>newBigInt(java.math.BigInteger.TEN) {}
129
+
<console>:11:warning: inheritance from classBigInt in packagemathisdeprecated:Thisclasswillbemadefinal.
This command allows a user to change already inserted commands. It is possible to change a range of lines. The syntax is:
143
+
144
+
- line number: 123 (only the line 123)
145
+
- range: 123-130 (the lines 123 to 130)
146
+
- offset: 123+7 (the lines 127 to 130)
147
+
- remaining: 123- (all lines up from 123)
148
+
- previous: -10 (the last ten lines)
149
+
150
+
The environment variable EDITOR is used to specify the editor to invoke. If EDITOR is not set or if the `:line` command is used instead of `:edit`, the selected text is added to the end of the history in order to allow fast editing by navigating through the history with the arrow keys.
0 commit comments