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

Add capability to reload Source objects. #23

Closed
wants to merge 3 commits into from

Conversation

chumer
Copy link
Member

@chumer chumer commented Jan 29, 2016

I needed the capability to reload sources. Especially with url caching this can be hacky. So I introduced a new method reload in Source that keeps the original source unmodified but reloads the code from the URL or File.

@mlvdv
Copy link
Contributor

mlvdv commented Jan 29, 2016

What's the use case?

@woess
Copy link
Member

woess commented Jan 29, 2016

Seems a bit strange to me. Wouldn't you rather want an uncached URL/File Source? You could then simply create a new one when you need it up-to-date.

@jtulach
Copy link
Contributor

jtulach commented Feb 1, 2016

There was d929423 and I got a feeling that Source is supposed to be immutable. That seems to be OK in this proposal, but the general motivation for the change is unclear.

@chumer
Copy link
Member Author

chumer commented Feb 1, 2016

I need the change in R to auto reload source files on changes. There is no way to reload a source from with a given URL atm. Its always returning the same Source object which caches the code as field and never reloads its contents.

We would not need this change if URL source would not cache their instances globally. I am happy to remove the cache instead.

@mlvdv I think you introduced the URL source cache. Do you remember its rationale?

@mlvdv
Copy link
Contributor

mlvdv commented Feb 1, 2016

No, I'm not sure what the conversation was about that. The original Source object wasn't much more than a collection of use cases in the different languages, since every language handled sources differently.

@woess
Copy link
Member

woess commented Feb 3, 2016

I think we should remove the current (static!) cache from Source. Perhaps we could split it out into a separate API that builds on top of Source that languages can optionally use if they need caching (e.g. "SourceCache"), perhaps tied to a PolyglotEngine instance?

@jtulach
Copy link
Contributor

jtulach commented Feb 3, 2016

OK. I prefer to remove the cache rather than trying to introduce an API for reload.

@jtulach
Copy link
Contributor

jtulach commented Feb 5, 2016

How such change affects Source.equals then? Right now it assumes that if Source comes from the same File/URL it is the same one. That will no longer be true - the equals will have to be modified to really compare the content.

@chumer
Copy link
Member Author

chumer commented Feb 9, 2016

I don't think Source#equals should compare the code for File sources or URL sources as they are mutable. For literal sources it might be a good idea to compare the sources itself on equals.

@chumer chumer closed this Feb 9, 2016
@chumer
Copy link
Member Author

chumer commented Feb 9, 2016

Closing. Will open another one where I remove the caching capability.

@jtulach
Copy link
Contributor

jtulach commented Feb 9, 2016

So what should Source#equals compare? Identity?

dougxc pushed a commit that referenced this pull request Apr 22, 2016
…truffle:prepare-0.13 to master

Ready to release version of truffle-0.13

* commit 'a4ac0aa8e852074b133f4d40f67c9c2a51a725da':
  Load the ContextStoreProfileTest test with the same classloader as the ContextStore classes.
  root is mutable instance variable - just checking against null doesn't provide much safety - using local copy
  Documenting SL JAR split
  Split TRUFFLE_SL_TEST out of TRUFFLE_SL
  Add maven-deploy dry-run to the gate
  Removing assignSourceSection and clearSourceSection from the API signature files
  Adding missing Javadoc with @SInCE tag
  Better formatting of the release 0.13 notes
  Adjusting the signature files to the state as of version 0.13
  Documenting what is new in version 0.13
  Remove deprecated source section API from Node.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants