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

How to deal with predicate defined in multiple files? #196

Open
s-webber opened this issue Dec 30, 2020 · 0 comments
Open

How to deal with predicate defined in multiple files? #196

s-webber opened this issue Dec 30, 2020 · 0 comments
Assignees
Labels

Comments

@s-webber
Copy link
Owner

How should Projog behave when a file defines a predicate that has already been defined by another file? This question was raised as an outcome of #195. Please see that issue for further information. The consult/1 predicate is used to read predicates from a file.

Current approach:

The current behavior of Projog is demonstrated in #195. If a predicate's clauses are defined across multiple files then the predicate must be defined as "dynamic". By default predicates are considered "static". The user must use the dynamic/1 to make it explicit that the predicate is dynamic.

A suggestion made in #195 was:

instead of specifying explicitly the dynamic aspect of a predicate, that is bit code intrusive and UX disadvantaging, to keep by default, as it the case today, predicates static and once updated, move them to dynamic, in total transparent way

Created this issue to review the current behavior and consider alternatives.

Possible approaches to dealing with a predicate being defined by multiple files:

  1. The new clauses could be added to the old clauses. This was the approach suggested in #.
  2. The new clauses could replace the old clauses.
  3. Projog could report an error and ignore the new clauses.

Things to consider:

  1. What would be most convenient for users of Projog?
  2. What is the most common approach implemented by other Prologs? From a quick search it appears that some Prologs support a multifile/1 predicate to indicate that a predicate may be defined over more than one file. Using multifile/1 has the same disadvantage as dynamic/1 in that it requires the user to specify that a predicate will be split across files, rather than Prolog dealing with it automatically. TODO: do some more investigation into how other Prologs behave.
  3. How easy would these approaches be to implement in Projog? Projog would need to undo any optimisations of a predicate if subsequent alterations meant they were no longer appropriate.

Further reading:

https://www.swi-prolog.org/pldoc/man?section=consulting
https://www.swi-prolog.org/pldoc/man?predicate=multifile/1
http://www.gprolog.org/manual/html_node/gprolog022.html#sec53
https://sicstus.sics.se/sicstus/docs/4.2.1/html/sicstus/Multifile-Declarations.html

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

No branches or pull requests

1 participant