Skip to content
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

Eliminate global mutable state. #33

Closed
eiriktsarpalis opened this issue Jan 21, 2014 · 1 comment
Closed

Eliminate global mutable state. #33

eiriktsarpalis opened this issue Jan 21, 2014 · 1 comment

Comments

@eiriktsarpalis
Copy link
Contributor

Much of the compiler code base currently relies on global mutable state. This comes with the following implications:

  • It is impossible to effectively parallelize calls to the service without sacrificing thread safety.
  • The service is not referentially transparent: identical inputs might generate slightly different assemblies, most importantly yielding incompatible names in generated closure types. This can be a serious problem when considering things like serialization.

We should improve this situation, either by making global mutable state thread safe or even completely refactoring the relevant code so that it becomes referentially transparent.

@eiriktsarpalis
Copy link
Contributor Author

I have an alternative proposal to solving this, which might not require as much refactoring as making a proper fix.

I propose we use thread-local dependency injection. You can find the gist of this pattern in this snippet. I have created a branch that explores on this idea. The fsc and fsi services are working properly and a couple of unit tests have been added that test parallel compilation and referential transparency.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants