Languages such as Lisp allow you to read an expression and to evaluate it,
returning a data structure. Prolog provides "evaluation"
only for arithmetic expressions, and then only in certain
library(activeread) provides a new experimental facility for reading
an arbitrary "expression" and "evaluating" it.
| ?- active_read(InputTerm).
reads a term from the current input stream. If this term has the form
X | Goal.
then Goal is called and InputTerm is unified with X. Otherwise,
unified with the term that was read. Note that Goal may backtrack, in
active_read/1 will also backtrack.
| ?- active_read(X). |: T | append([1,2],[3,4], T). X = [1,2,3,4] yes
| ?- active_read(X). |: Front+Back | append(Front, Back, [1,2,3,4]). X = +[1,2,3,4] ; X = +[2,3,4] ; X = [1,2]+[3,4] ; X = [1,2,3]+ ; X = [1,2,3,4]+ ; no
| ?- active_read(X). |: abort. X = abort yes
library(activeread) is not a module-file, but it is sufficiently small that
there should be no problem with including a separate
copy in each module where it is required.