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

Implementing THE top-level loop ourselves #1

Open
guicho271828 opened this issue Jan 4, 2018 · 3 comments
Open

Implementing THE top-level loop ourselves #1

guicho271828 opened this issue Jan 4, 2018 · 3 comments

Comments

@guicho271828
Copy link
Collaborator

Although the top level loop on each prolog is not compatible, we can instead write a toplevel loop ourselves.

@guicho271828
Copy link
Collaborator Author

@triska are you interested in it? I am not working on implementing the toplevel loop since I mostly use this library for batch processing. I am happy to see PR from somebody

@triska
Copy link

triska commented Feb 4, 2018

Yes, I'm definitely interested in a portable Prolog toplevel! Conceptually, I think it is a very fitting approach for your use case. In addition, I could also use it to make ediprolog portable across different Prolog systems without changing the Elisp code.

See also triska/ediprolog#2, where I have filed the exact same issue.

Recent ISO work has provided some of the necessary building-blocks that will eventually make a portable toplevel possible. However, a lot of the necessary functionality is still only available in a mostly ad hoc way in many implementations. Therefore, although I consider the issue currently a bit out of reach, I will definitely help in every way I can if someone wants to work on this!

Some important constructs:

  • call_residue_vars/2 and copy_term/3 to obtain pending residual goals (note: not fully portable between SICStus and SWI, but can be worked around with if/endif directives!)
  • setup_call_cleanup/3 to detect whether choice-points are left (note: mostly portable between implementations that provide it, but lacking in some systems)
  • variable_names/2 read and write options to read and emit variables names (made available in a recent corrigendum).

This should suffice to get most of the functionality, but actual text input still needs to be covered for convenient interaction (single char input etc.), and is not particularly portable between implementations.

@guicho271828
Copy link
Collaborator Author

OK, it sounds like you write the loop in prolog, not in our lisp-prolog DSL. Fine, it still works for us.

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

No branches or pull requests

2 participants