SWI-Prolog / packages-pengines

Pengines: Prolog engines
11 stars 13 forks source link

Allow no-chunking behavior for pengines. #56

Closed meditans closed 8 months ago

meditans commented 8 months ago

The old options chunk(integer) is now optional. In the case it's not set, we fall back to a non-chunking behavior that avoids the usage of findnsols (and the effects on global variables associated with its backtracking). Initially, this was motivated by the fact that I wanted the pengine top-level (which is recursive in nature) to respect the chr store, but I also think it's a more principled thing to do.

JanWielemaker commented 8 months ago

This pull request has been mentioned on SWI-Prolog. There might be relevant details there:

https://swi-prolog.discourse.group/t/persistent-chr-store/6977/15

meditans commented 8 months ago

In reality, I think it would have been clearer if I could have specified the chunk option as: oneof([integer, no_chunk]), but that wasn't the semantic of oneof. If you have better suggestions here I'm eager to hear them.

JanWielemaker commented 8 months ago

Thanks. Edited and changed somewhat. I agree that relying on a lacking chunk is not good and breaks e.g., SWISH. Of course, that can be fixed in SWISH. but as SWISH and Prolog develop independently that will lead to problems.

There are disjunctive types, so it now supports chunk=false. Hope that satisfies your requirements.

Note that I edited your commit, so it is applied but reported as a conflict.

Please close this PR if you agree.

meditans commented 8 months ago

Thank you for reviewing and merging, in the current version I'm hitting a type error when I try to use chunk=false:

Type error:integer' expected, found no_chunk' (an atom)

I'll try to look into it tomorrow and suggest a patch, as another PR. I'll close this one in the meantime, thanks again!