-
Notifications
You must be signed in to change notification settings - Fork 14
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
Double execution does not work properly #72
Comments
Thanks for opening this issue. Currently the only way to avoid is by restarting the kernel. Clang-Repl supports unrolling to the previous state and we "just" need to implement it. The reliability of that feature is not the best in clang-repl but it will be a good start. The idea is that we need to count the number of cells, |
Apparently the problem was fixed in Cling 0.7.0 by implementing a function allowRedefinition(). There was a similar issue in xeus-cling (jupyter-xeus/xeus-cling#91). I can't seem to find similar function in clang-repl. Maybe this could be suggested to upstream? UPD: related links |
Redefinition would mean that double d = 12.; and std::string d = "12"; would work across cells. That does not necessarily mean that we can re-execute cells. One of the most controversial feature of the implementation in cling is that we mess up with the lookup tables in the compiler which is perhaps not the best idea. PS: This implementation does not have a lot of chances to go upstream in clang. We should probably figure out how to make it less intrusive. |
As far as I understand, something involving nested inline namespaces was used to implement this in cling. |
I think the approach with |
You will not going to lose it as it will still be on the notebook but the internal state of the infrastructure should be as if it was rewinded to that place. I am not sure I see how else that could be done even on the python end. We cannot really reason about dependency graphs and connectivity as generally subsequent computations depend on previous ones. That is, generally there might have been some disconnected graph that does not affect what you want to undo, however, in practice that seems to be hardly the case. PS: Consider: cell 1: int i = 12; If you want to change/re-execute cell 2, the data in cell 3 is invalid anyway. If we consider cell 4, do you expect the result in cell 3 to be |
Not really, I meant the following
Here I expect to be able to access UPD: perhaps this should be limited to only objects, and not functions. |
Ok, I see but I fail to see the use-case. If |
Yes, the program is essentially invalid in its current state, but the invalid piece of code wasn't executed, so it should be possible to access the results of the code, whatever they were (even if that's generally UB, as the underlying internals might change). P.S. Is it possible to maybe implement nested inline namespaces without messing with the compiler internals? I think this would produce the desired behaviour. |
Probably, can you make a prototype in godbolt to see how that'd work? |
Something like this, maybe (I would rather have named namespaces though). UPD: a bit more sophisticated example: https://godbolt.org/z/6c6PMrzPK |
Did I understand you correctly about the prototype or did you mean something else? |
I think I have a more desirable variant using C++17 syntax that does not require full recompiling to add new block. |
Thanks for working on this. I believe there are two aspects that are somewhat relevant here. Redefinition of entities which allows us to use the same name with different meaning, and re-running cells. If you want to rerun cells I believe we really need to use the watermarking approach described earlier here |
I've implemented my approach using C++17 nested namespaces syntax in the PR #80 (it is very similar to the approach in the article, at least according to the abstract, but it doesn't require any messing with lookup tables). |
Hi @p4vook, This is Javier, one of the authors of the implementation (and the related ACM CC paper) of entity redefinition in cling. Apologies, I was totally unaware of the existence of this issue. For Other than that, I hope that you had a wonderful entry into 2024! Cheers, |
Hi, @jalopezg-git! I would be glad to tell you any details I learned about this. It's all pretty much described in the links below:
I'd love to join the discussion about any of these problems. The entry into 2024 was, indeed, not too bad. Hope yours was wonderful. |
Oh, god! I totally forgot replying here! It has been a few quite hectic months at work... 😅 Is there any news on this? I might have some time now in Summer to do something on it, if needed! |
Hi @jalopezg-git, great to hear from you! We have moved to a new repository: compiler-research/xeus-cpp. If we do work it needs to be there. |
Currently, if a cell with some definitions is executed twice, the second time will drop an error. I think, this behavior is undesired, because it doesn't allow modifying functions in cells.
Is there any way to overcome this?
The text was updated successfully, but these errors were encountered: