Re: any static state in scala.tools.nsc.Global?
Simon Schäfer <[email protected]> Fri, 25 Mar 2016 12:31:18 +0100
| Newsgroups | gmane.comp.lang.scala |
|---|---|
| Message-ID | <[email protected]> |
On 03/25/2016 05:11 AM, P. Oscar Boykin wrote: > The name scares me that it might be squirreling away some state, but > if I were to instantiate this: > > https://github.com/scala/scala/blob/2.11.x/src/compiler/scala/tools/nsc/Global.scala > > 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. 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 [email protected] > <mailto:[email protected]>. > For more options, visit https://groups.google.com/d/optout. -- 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 [email protected]. For more options, visit https://groups.google.com/d/optout.