any static state in scala.tools.nsc.Global?

46 views
Skip to first unread message

P. Oscar Boykin

unread,
Mar 25, 2016, 12:11:59 AM3/25/16
to scala-language
The name scares me that it might be squirreling away some state, but if I were to instantiate this:


and pass it the same options the command line wound have in scalac, can I expect that all state is reset on each new instantiation?

What I am really trying to do is be able to get the jit to run on the code, leave a compiler resident and have it compile without one run changing the state of the next (for the bazel build system: https://github.com/bazelbuild/rules_scala ). Bazel's model makes zinc integration a challenge (maybe doable, but this is a first step anyway).

Any feedback on what I am trying to do would be great.

Simon Schäfer

unread,
Mar 25, 2016, 7:31:23 AM3/25/16
to scala-l...@googlegroups.com
Multiple instances of Global should be safe. Can't say if it is 100% safe, maybe there is some state leaked somewhere but I never had a problem with multiple instances of Global. A single instance however is not safe to use because it leaks a lot of state internally, which means if you compile the same code twice by the same Global it may happen that the first time it works fine and the second time it doesn't. From a design point of view, using a new instance of Global is the way to go. However, since you have to pay a huge startup time for every creation of Global it can be necessary to reuse Global and pay for additional implementation complexity. But that depends on your use case.
--
You received this message because you are subscribed to the Google Groups "scala-language" group.
To unsubscribe from this group and stop receiving emails from it, send an email to scala-languag...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply all
Reply to author
Forward
0 new messages