Dynamic runtime predicate pointer binding
Posted: 28 Apr 2014 9:38
Pseudo Code.
This is a contrived example of the kind of thing that I wish to do.
Can I set up a fact or property or domain to allow what could be called runtime binding so that either the doNothing predicate gets called or writeToConsole gets called based on a runtime test.
Thanks for your trouble
Code: Select all
facts
predicate_pointer : pointer(string).
predicates
doNothing:(string).
writeToConsole:(string).
app_init().
doLotsOfWork().
clauses
app_init():-
if (debug_condition=true())
predicate_pointer := writeToConsole()
else
predicate_pointer := doNothing()
end if.
doLotsOfWork():-
repeat(),
LineVal = InStream:readLine(),
predicate_pointer(LineVal),
fail.
Can I set up a fact or property or domain to allow what could be called runtime binding so that either the doNothing predicate gets called or writeToConsole gets called based on a runtime test.
Thanks for your trouble