5

What I'm Doing

I am currently working on creating a SWI-Prolog module that adds tab-completion capability to the swipl-win window. So far I've actually gotten it to where it reads a single character at a time without stopping/returning anything until a tab character is typed. I have also already written a predicate that returns all possible completions of an incompletely typed term by using substring-matching on a list of current terms (obtained via current_functor/2, current_arithmetic_function/1, current_predicate/2, etc [the predicate used will eventually be based off of context]).

If you want to see my code, it is here...just keep in mind that I'm not exactly a Prolog master yet (friendly tips are more than welcome).

Note: The "Hey, does this match any defined term so far?" predicate only checks if there are any current predicates, etc that start with the substring right now. Eventually, it will use context ("Is the caret in the middle of a 'word'?") to determine where the substring should be located in any potential completions.


What I'm Thinking

Currently I have said predicate matching strings (not atoms) because I read that strings are easier on memory and such because they don't have to be unique like atoms, etc...but I'm not sure if it's worth it if I might just be converting things to strings first (depending on how I read in the term; I'm considering using with_output_to to write directly to a string), and then the atoms would have just been created anyway. (Hopefully I don't sound too confused.) Now I'm just trying to decide whether to use atoms or strings. (But don't strings count as atoms?)

Note: Much of this depends on the answers I get to this question, because I'm going to base my decision on the use of strings in this project off of them.


What I'm Asking

Should I use strings (and therefore sub_string/5) or atoms (and therefore sub_atom/5)?

Community
  • 1
  • 1
ksoo
  • 434
  • 1
  • 3
  • 15

0 Answers0