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
Feature Request: Persistent constraint store in top-level #3
Comments
As stated, I don't think that CHR is the place to change this. It would need to go into boot/toplevel.pl, There is one issue: if the user makes some error the exception will still tear down the CHR store. This can be avoided using a catch/3, but as the comment above already states, this means the exception will not be considered `uncaught' and the toplevel won't do its normal magic with uncaught exceptions. It is not entirely sure how to remedy that. Possibly with a foreign routine for calling the actual goal. There is probably also some magic needed to switch between the two styles. The alternative is to implement e.g. chr/0 that will run the alternative toplevel. Not sure what is best. Guess it depends on whether or not this makes any sense outside the context of CHR. In theory you can have other stuff depending on global variables, but I'm not aware of a concrete similar example. |
The same use-case might apply for
Maybe @triska can tell if this a desired behaviour for |
@fnogatz: Please post this question, suitably generalized, to stackoverflow.com, using the
There are several ways to do this, and it would be great to see the feedback from other Prolog vendors too. |
As the toplevel is a pretty complex beast, I've done a little hacking myself. Using the latest GIT version you can do
and backtrackable global variables are maintained. This also causes toplevel bindings to be maintained on the stacks without copying them, so $Var refers to a not copied previous answer. Experience will show |
Jan, thanks for adding this. I installed latest GIT version and for CHR it is now working as I had in mind. However, it does not seem like a general solution, as
|
It works, but differently. First of all
I doubt that is what we want. You can refer to old answer variables using $Var, as you could always do in SWI-Prolog, except that before $Var would refer to a copy while now it refers to the real answer. So,
Now it only might make sense to make it write
That might be feasible. |
Thank you for the clarification. The shorter notation you suggested at the end, i.e. returning |
As already discussed in pull request #2 it is a common request to have a persistent constraint store in SWI's top-level. My suggestion was to have a new
chr_option(persistent_store, OffOn)
. Unfortunately it is not enough to simply prevent the top-level's backtracking by changing the usedb_setval
intonb_setval
for saving constraints.@JanWielemaker already proposed some thoughts on this in #2:
I am willing in implementing an alternative approach again, but I am not sure if the requested behaviour is ok for Jan and which would be the best starting point for implementation. Let's use this issue to track this down :)
The text was updated successfully, but these errors were encountered: