Scheme it’s strength in it’s strong foundation of theory and most things are composable in a general and sound way. For example the ability to take a function goal and output a new function goal to attach properties to that function is a bit clumsy in prolog. Therefore if you prepend a functor that map functions to functions you may get a nice an tidy syntax. The rule is
- rec(guard,action). - functorize(tabling). f(X) :- ... - recursive. g(X) :- .... - recursive. - functorize(tabling). h(X) :- ...
We see two ways of entering a functor, the first one is
prolog -functor(arg1, ..., argn). This is assuming that functor is a scheme function defined as
Scm (functor f arg1 arg2 ... argn).
f is the lambda that is defined by all the functors below and the actual function definition.
The othe uses the meta functor
functorize, the signature is
prolog functorize(goal, arg , ...) Here goal would be something like
G.L. (goal f arg ... x ...) e.g. goal will be as executeing
G.L. (f x ...) but with the new properties added. The reason for this complexity are that normal functors are not goals, but goal functions that maps goal functions, in it’s first argument, need to be wraped with
Examples of functors and goal functors to use are
tabling etc found in
(logic guile-log memoize), and also
adaptable_vars that tells that all variables created in the function should use a default attribute constructor if defined, this defined in