-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Dotty REPL initial version #1082
Conversation
Explanations, copied from comment on This REPL was adapted from an old (2008-ish) version of the Scala
The reason this version was picked instead of a more current one is that There are a number of TODOs:
|
private var binderNum = 0 | ||
|
||
override def bind(name: String, boundType: String, value: Any)(implicit ctx: Context): Interpreter.Result = { | ||
val binderName = "binder" + binderNum |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe binder$
to ensure absence of name clashes?
I'd be interested in hearing from @retronym or others familiar with the scalac REPL (@som-snytt ?) about pitfalls we could fall into and mistakes we are likely to repeat. (Suggestions on cool things we could do are also welcome!) |
I subscribed to this PR this morning because I'm interested in contributing code. I'll make an effort to make time for it. |
@odersky To launch repl with scala I used: scala -J-Xbootclasspath/a:\
[path]/.ivy2/cache/me.d-d/scala-compiler/jars/scala-compiler-2.11.5-[version-info].jar:\
[path-to-dotty]/dotty/bin/../target/scala-2.11/dotty_2.11-0.1-SNAPSHOT.jar \
dotty.tools.dotc.repl.Main Fork of scala compiler from me.d-d and dotty are added to bootclasspath. |
Adding tab completion support to the REPL will be a good way to start experimenting with ways to make the typechecker IDE friendly, without the waiting for integration into Eclipse. This will be handy to validate that the parser and typechecker are fault tolerant and don't discard trees that correspond to the textual sources. See scala/scala#4766 for an example of such a problem in Scalac, and scala/scala#4725 for the change to use the presentation compiler to drive tab completion. Try to avoid splicing user-written code into the synthetic wrappers as text. Ideally you want to be able to typecheck the expression as entered after programattically setting up a typechecker context that includes the imports of previously defined symbols and with previously entered imports. Once that is typechecked, it could be spliced into the synthetic wrapper via AST manipulation. This avoids awkward problems of quoting / escaping, and could probably avoid the need to have the deeply nested |
@@ -1,20 +0,0 @@ | |||
object Test { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why was this test deleted?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
t920 fails on MacOS. See #1077. I'll push a version in pending.
On Mon, Feb 15, 2016 at 3:01 PM, Guillaume Martres <notifications@github.com
wrote:
In tests/run/t920.scala
#1082 (comment):@@ -1,20 +0,0 @@
-object Test {Why was this test deleted?
—
Reply to this email directly or view it on GitHub
https://github.com/lampepfl/dotty/pull/1082/files#r52901262.
Martin Odersky
EPFL
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll push a version in pending.
What about just renaming b
to something else?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Then I don't know what it would test?
On Mon, Feb 15, 2016 at 5:40 PM, Guillaume Martres <notifications@github.com
wrote:
In tests/run/t920.scala
#1082 (comment):@@ -1,20 +0,0 @@
-object Test {I'll push a version in pending.
What about just renaming b to something else?
—
Reply to this email directly or view it on GitHub
https://github.com/lampepfl/dotty/pull/1082/files#r52920045.
Martin Odersky
EPFL
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure either, but I don't think that this test was added to scalac to test for that, cf https://issues.scala-lang.org/browse/SI-920 and scala/scala@485a79a#diff-2a17630cbd90645d1f9a67af6e848c30
If it doesn't test anything useful then we can just drop it.
@som-snytt Contributions are very welcome! |
After discussion at dotty meeting we decided to merge |
The interpreter needs to install a virtual directory as output directory. This is not supported with the -d option in ScalaSettings. The solution is to make the output directory overridable in the GenBCode phase.
Allows to replace existing phase by sequence of new phases.
Adaptation of REPL by Spoon from ca 2007. Compiles OK, but not yet tested.
Makes side-effecting initialization of interpreter unnecessary.
Changes necessary to make basic REPL functionality work. Major refactoing: Code of Interpreter is now in CompilingInterpreter.scala. Interpreter.scala contains just the API.
When defining a class in the interpreter we had a case where the class was accessed at phase 46 in the backend, yet the denotation was the initial denotation in a previous run. In that case we have to check again at the phase where the denotation is valid. This was not done before, and hence the owner of the denbotation did not contain the symbol because the backend phase is after flatten.
It seems some symbols are valid from NoPhase (0). In any case, we should not check members before typerphase.
Avoids line$object... gunk.
Got deleted by accident. Version in run has object renamed to prevent case clashes on MacOS. Version that exhibits the clash is in pending/run.
Seems to be overkill for the current interpreter. The only thing that was needed was a configrable linewidth. A plain setting works fine for this and is in line with the way things are done elsewhere.
compileString is not needed and does not what one might expect (no wrapping). So it should not be exported.
An initial version of a REPL for Dotty. Basic functionality works.
Class
dotty.tools.dotc.repl.Main
is the main entry point. To start the REPL, before we have a dedicated command, use(when started under scala, it does not find an Execution context. Hopefully somebody else is better than me at figuring this out).
A comment below explains how the REPL code was derived, and contains a list of TODOs with suggestions to improve it. I am very much hoping for the contributions of others to move this forward.
Review by @hubertp or @DarkDimius or @smarter or anybody wishing to contribute.