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
Copy file name to clipboardExpand all lines: contribute/hacker-guide.md
+15-9Lines changed: 15 additions & 9 deletions
Original file line number
Diff line number
Diff line change
@@ -160,20 +160,26 @@ Here are also some tips & tricks that have proven useful in Scala development:
160
160
* Don't underestimate the power of `print`. When starting with Scala, I spent a lot of time in the debugger trying to figure out how
161
161
things work. However later I found out that print-based debugging is often more effective than jumping around. While it might be obvious
162
162
to some, I'd like to explicitly mention that it's also useful to print stack traces to understand the flow of execution. When working with `Trees`, you might want to use the Scala `showRaw` to get the `AST` representation.
163
-
* You can publish your newly-built scala version locally using `sbt publishLocal` to use it from `sbt`. Here's how:
163
+
* You can publish your newly-built scala version locally using `sbt publishLocal`. Then, you can invoke a REPL using your version:
164
164
165
165
$ sbt publishLocal // This may take a while
166
166
...
167
167
$ sbt
168
168
...
169
-
> console
170
-
[info] Starting scala interpreter...
171
-
[info]
172
-
Welcome to Scala version 2.10.6 (OpenJDK 64-Bit Server VM, Java 1.8.0_91).
Welcome to Scala 2.12.0-20160613-195040-cd85531 (OpenJDK 64-Bit Server VM, Java 1.8.0_91).
172
+
Type in expressions for evaluation. Or try :help.
173
+
174
+
scala>
175
+
176
+
Alternatively, you can invoke a REPL using the bash script in `./build/quick/bin/`:
177
+
178
+
$ ./build/quick/bin/scala
179
+
Welcome to Scala 2.12.0-20160613-195040-cd85531 (OpenJDK 64-Bit Server VM, Java 1.8.0_91).
180
+
Type in expressions for evaluation. Or try :help.
181
+
182
+
scala>
177
183
178
184
* Adding a macro to the `Predef` object is a pretty involved task. Due to bootstrapping, you cannot just throw a macro into it. For this reason, the process is more involved. You might want to follow the way `StringContext.f` itself is added. In short, you need to define your macro under `src/compiler/scala/tools/reflect/` and provide no implementation in `Predef` (`def fn = macro ???`). Now you have to set up the wiring. Add the name of your macro to `src/reflect/scala/reflect/internal/StdNames.scala`, add the needed links to it to `src/reflect/scala/reflect/internal/Definitions.scala`, and finally specify the bindings in `src/compiler/scala/tools/reflect/FastTrack.scala`. [Here's](https://github.com/folone/scala/commit/59536ea833ca16c985339727baed5d70e577b0fe) an example of adding a macro.
0 commit comments